1

I found this query in elasticsearch docs link to docs

GET /seats/_search
{
  "size": 0,
  "aggs": {
    "theatres": {
      "terms": {
        "field": "theatre",
        "size": 10
      },
      "aggs": {
        "max_cost": {
          "max": {
            "field": "cost"
          }
        },
        "filtering_agg": {
          "bucket_selector": {
            "buckets_path": { 
              "max": "max_cost"
            },
            "script": {
              "params": {
                "base_cost": 5 
              },
              "source": "params.max + params.base_cost > 10"
            }
          }
        }
      }
    }
  }
}

here size is 10 in theatre parent aggregation and inside child aggregation we have condition on bucket, so if parent aggregation gives 10 documents and bucket_selector filter removes 4 documents then final result has 6 documents, i want final result to have 10 documents as mentioned in parent aggregation size field, is there any way to achieve this. can we include size after bucket_selector and remove size for parent aggregation.

Akash Salunkhe
  • 194
  • 2
  • 13

0 Answers0