I was able to model a way to return a set of documents deduplicated by field from the accepted answer in this post:
Filter elasticsearch results to contain only unique documents based on one field value
The problem is the response payload includes several of the full documents first, followed by the aggregations
object, whereas I only want the aggregations
object returned. How would I do this? I tried playing with different variations of _source
to limit what's returned, but not surprisingly, none of my attempts are working.
CodePudding user response:
You must add the size = 0
parameter in your elasticsearch query if you wish to return just aggregations results.
The structure of the query will look like this:
{
"size": 0,
"query": {},
"aggs": {}
}