Skip to content Skip to sidebar Skip to footer

How To Merge Two Dsl Query For Aggregation And Filter

I need to search BusinessArea which is Research or Accounting this is array of fields(OR) statement I need to search Role is Developer or Tester condition this is array of fields(

Solution 1:

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"
      }
    }
  }
}

Post a Comment for "How To Merge Two Dsl Query For Aggregation And Filter"