Filter documents using aggregation in Discover

Need to filter the documents based on aggregated results in kibana discover .

{
  "aggs": {
    "match_id": {
      "terms": {
        "field": "MATCH_ID",
        "size": 10000
      },
      "aggs": {
        "count_id": {
          "terms": {
            "field": "MATCH_ID"
          }
        },
        "filtering_agg": {
          "bucket_selector": {
            "buckets_path": { 
              "total_ids": "count_id"
            },
            "script": {
              "source": "params.total_ids == 2"
            }
          }
        }
      }
    }
  }
}

is there any way to apply aggregation and filter documents in Discover .

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