Post filter not returning expected results

Hi,

I want to filter the stats returned by the extended stats aggregation. I basically need to filter out all values of avg that are 0.

Below is the query on which I need to apply the post filter but I am not sure how should I apply the post filter when I want to filter out a particular value. Could you please help. Thanks in advance.

    "aggs": {
      "variable_grp": {
        "terms": {
          "field": "variable",
          "size": 200,
          "order": { "stats.avg": "asc" }
        },
        "aggs": {
          "stats": {
            "extended_stats": { "field": "value_num" }
          }
        }
      }
    }, 
    "size":0

You'll need to use a BucketSelector pipeline agg, not the post_filter.

A post filter is used to filter the search hits after aggregation results have run. It's often used for faceted navigation, so that clicking on a navigation facet in a UI changes the search results without changing the facets.

In your case, you want to "prune" out buckets with a specific value, which is what the bucket_selector pipeline agg does :slight_smile:

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