As for search queries , they are the same, i.e. hits you get will be correctly filtered according to your filter in the filtered request or in the filter in post_filter .
However, with regard to aggregation , the end result will be different. The difference between both parameters depends on which document sets the units.
If your filter is in the filtered request, then your aggregations will be calculated by the set of documents selected by the request (s) and the filter (s) in your filtered request, that is, in the same set of documents that you will receive a response.
If your filter is in post_filter , your aggregations will be calculated based on the set of documents selected by your various query (s). After aggregations have been calculated in this set of documents, the latter will be filtered by filters (s) in your post_filter before returning the corresponding documents.
Summarizing,
- a
filtered affects search and aggregation results - whereas
post_filter only affects search results, not aggregation
source share