HOw can I get aggregations based on query only and based on filters (post_filter) at the same time

Greetings everyoune!

My questions is:
Is there any way to process aggregations depend on filter (bool query or post_filter) and aggregations based on query only?

I.e.
I have a document - product. I have several products in index.
The product structure is:
id
name
categoryId
price.

All I want is to find products by "name" property, then collect information about categories that has the document matches query, then filter them by categoryId (cat1, cat2) then I want to get an information about maximum and minimum product price within the categories (cat1 and cat2)

I think you can use the filters aggregation to do this. Still your post
filter in there and the bits that don't match will be in the other
bucket.

Can you, please, show me an example? I can use BoolQuery.Should instead of post_filter - this is not principal. The only thing I need is to have an aggs before filtering and after filtering.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.