Post-Filter After Aggregation on Search Query

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Version 2.6

Describe the issue:
I am building a faceted search query that needs to do three things, in this order:

  1. Match and pre-filter results.
  2. Return several aggregations based on various document fields, providing the counts for our facets.
  3. After retrieving aggregation results, apply a post-filter to the pre-filtered results.

Elasticsearch has a feature called “post-filter” which does this. This helps with implementing facets, since it’s desirable for the user to be able to view the count of different document categories even after selecting a facet for filtering. How can we replicate post-filtering in OpenSearch?

OpenSearch also has post filter functionality, but currently it’s not documented, you can use it as you use in Elasticsearch.

1 Like

Oh, that is a relief to hear! Thanks for letting me know!