Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perform Elasticsearch aggregation without returning hits array

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?

like image 565
Yi Z Avatar asked Dec 14 '14 09:12

Yi Z


People also ask

What is top hits aggregation Elasticsearch?

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.

Is Elasticsearch good for aggregation?

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.

Can Kibana perform aggregation across fields that contain nested objects?

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.

What is cardinality aggregation Elasticsearch?

Cardinality aggregationedit. A single-value metrics aggregation that calculates an approximate count of distinct values.


1 Answers

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

like image 165
eliasah Avatar answered Oct 08 '22 13:10

eliasah