How to exclude keys by multi-terms/composite aggregations

Hi, I am writing an composite aggregation in Elasticsearch like the following:

POST family_predicted_data/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "terms": {
            "query_id": [
              1
            ]
          }
        }
      ]
    }
  },
  "aggs": {
    "num_families": {
      "value_count": {
        "field": "family_id"
      }
    },
    "members": {
      "nested": {
        "path": "members"
      },
      "aggs": {
        "continent_assignee": {
          "composite": {
            "sources": [
              {
                "continent": {
                  "terms": {
                    "field": "members.country.keyword",
                    "exclude": ".*"
                  }
                }
              },
              {
                "assignee": {
                  "terms": {
                    "field": "members.assignee.keyword"
                  }
                }
              }
            ]
          },
          "aggs": {
            "num_families": {
              "reverse_nested": {}
            },
            "sort": {
              "bucket_sort": {
                "sort": [
                  {
                    "num_families>_count": {
                      "order": "desc"
                    }
                  }
                ],
                "size": 5
              }
            }
          }
        }
      }
    }
  },
  "track_total_hits": true,
  "size": 0
}

Normally terms aggregations have a exclude parameter to exclude keys. In my case I have some keys that are empty strings because of some dirty data. Running this query, I get the following error message:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "x_content_parse_exception",
        "reason" : "[33:21] [terms] unknown field [exclude]"
      }
    ],
    "type" : "x_content_parse_exception",
    "reason" : "[33:32] [composite] failed to parse field [sources]",
    "caused_by" : {
      "type" : "x_content_parse_exception",
      "reason" : "[33:21] [terms] unknown field [exclude]"
    }
  },
  "status" : 400
}

It seems like there is no exclude option for composite aggregations? Is there any other way to exclude such cases where one of the fields have empty strings?

Thanks in advance!

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