how to merge two dsl queries for aggregation and filtering?

Nice start !!! Now you can simply combine all those snippets like this:

{
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "name.keyword": "Group1"
          }
        },
        {
          "terms": {
            "BusinessArea.keyword": [
              "Research",
              "Accounting"
            ]
          }
        },
        {
          "terms": {
            "Role.name.keyword": [
              "Developer",
              "Tester"
            ]
          }
        }
      ]
    }
  },
  "aggs": {
    "countNames": {
      "terms": {
        "field": "BusinessArea.keyword"
      }
    },
    "designationNames": {
      "terms": {
        "field": "Designation.keyword"
      }
    },
    "Role": {
      "terms": {
        "field": "Role.name.keyword"
      }
    }
  }
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top