Is it possible to query for all of the values a specific field? Say I have "articles" and each article has an author, is there a query I can perform to find a list of all authors?
Here are three popular methods, you use to export files from Elasticsearch to any desired warehouse or platform of your choice: Elasticsearch Export: Using Logstash-Input-Elasticsearch Plugin. Elasticsearch Export: Using Elasticsearch Dump. Elasticsearch Export: Using Python Pandas.
The _source field contains the original JSON document body that was passed at index time. The _source field itself is not indexed (and thus is not searchable), but it is stored so that it can be returned when executing fetch requests, like get or search.
You can use the search API to search and aggregate data stored in Elasticsearch data streams or indices. The API's query request body parameter accepts queries written in Query DSL. The following request searches my-index-000001 using a match query. This query matches documents with a user.id value of kimchy .
How to get all possible values for field
author
?
curl -XGET http://localhost:9200/articles/_search?pretty -d ' { "aggs" : { "whatever_you_like_here" : { "terms" : { "field" : "author", "size":10000 } } }, "size" : 0 }'
Note
"size":10000
Get at most 10000 unique values. Default is 10.
"size":0
By default, "hits"
contains 10 documents. We don't need them.
By default, the buckets are ordered by the doc_count
in decreasing order.
Reference: bucket terms aggregation
Also note, according to this page, facets have been replaced by aggregations in Elasticsearch 1.0, which are a superset of facets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With