I've been unable to tell the server that I don't want any non-aggregate documents to come back so I have to accept one back (hence size:1). As I am only interested in the aggregation results, this feels like a hack - is there a better way of limiting the scope of my aggregation search and thus avoiding having matched documents returned?
My application expects the aggregation results to be returned in full. In our case it's unlikely to result in more than 2,000 documents so I've set this as the size however this too feels like a hack. Is there a better way?
This is odd, whats wrong with ommiting the "query" part and setting the size to 0 if you don't want any search hits? I might be misunderstanding the question though.
What kind of aggregation result is this? As far as I know the size parameters in aggregations are specific to the kind of aggregation you are using (e.g. terms)
The query limits the aggregation to the documents of interest (a where clause, if you will). For instance, those within a particular time range.
Using size: 0 results in an error that the value must be a positive integer.
I have a date_histogram and aggregations including terms, cardinality and sum. The terms ones are bounded with a size after we discovered that without this parameter only the first ten results would be returned.
Thats the odd part. It shouldn't do that. You are essentially scoping your aggregation as described here. Setting a size of 0 to omitt the seach results while still having a query to scope the aggregation is the normal thing to do here. Please check those examples, maybe you can spot the difference.
Yes, you explicitely need to set the size for the terms aggregation since it will also affect the way the aggregation is computed as explained here.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.