Reputation: 277
I am trying to utilize the aggregations feature in elasticsearch.
I searched for information about this and came across this very useful article on aggregations. https://www.found.no/foundation/elasticsearch-aggregations/ But I am not able to find any information about filtering and pagination in combination with aggregation
Upvotes: 1
Views: 2320
Reputation: 4626
From the ElasticSearch guide on aggregations (emphasis mine):
An aggregation can be seen as a unit-of-work that builds analytic information over a set of documents. The context of the execution defines what this document set is (e.g. a top-level aggregation executes within the context of the executed query/filters of the search request).
So yes, you can filter a set of documents and only then apply the aggregation, by using a query followed by an aggregations clause.
{
"query": { /* any query */ },
"aggs" : { /* aggregations on resulting documents */ }
}
I don't think you can paginate through aggregation results, but perhaps from
and size
would work.
Upvotes: 3