Typically, search results and aggregation results refer to the same query. If we want to display the search results and the aggregation results in different ways—such as applying filters to display narrowed-down search results—then we can run post_filter after the query. The post_filter parameter has no effect on aggregation. For example, let's use post_filter in the example of the term bucket aggregation. We only want to retrieve the rating = 5 documents in the search result, which is at the top of the result from the term aggregation on all of the rating field values.
In the following screenshot, only the rating = 4 documents are retrieved back, and the total hits is 34 instead of the total 314 documents: