Im using ES 1.4. When I perform an aggregation, the result returns the hits array as well. Is there a way to only return the aggregations?
A top_hits metric aggregator keeps track of the most relevant document being aggregated. This aggregator is intended to be used as a sub aggregator, so that the top matching documents can be aggregated per bucket.
Elasticsearch Aggregations provide you with the ability to group and perform calculations and statistics (such as sums and averages) on your data by using a simple search query. An aggregation can be viewed as a working unit that builds analytical information across a set of documents.
But visualizations in Kibana don't aggregate on nested fields like that, regardless of how you set your mappings -- if you want to run aggregations on the data in the items list, you aren't going to get the results you are looking for. Then doing the same sum aggregation should return the expected results.
Cardinality aggregationedit. A single-value metrics aggregation that calculates an approximate count of distinct values.
You would have to specify in the query that the size is equal to 0
ex :
{ "query": ... , "aggs": ... , "size": 0 }
Related doc page on ES website: https://www.elastic.co/guide/en/elasticsearch/reference/current/returning-only-agg-results.html
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