Elasticsearch 2.x - Multiple filter inside should


(Diego Corradini) #1

After upgrading to ES 2.x I have an issue with the following query:

{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "should": [
            {
              "bool": {
                "must": [
                  {
                    "terms": {
                      "_type": [
                        "xxx",
                        "yyy"
                      ]
                    }
                  },
                  {
                    "exists": {
                      "field": "aaa"
                    }
                  },
                  {
                    "exists": {
                      "field": "bbb"
                    }
                  },
                  {
                    "exists": {
                      "field": "ccc"
                    }
                  }
                ]
              }
            },
            {
              "bool": {
                "must": [
                  {
                    "term": {
                      "_type": "eee"
                    }
                  },
                  {
                    "term": {
                      "f": 0
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    }
  }
}

Basically, I do not know how to replace the 'must' inside the 'should' filter with the new DSL query of ES 2.x.

Thanks in advance.


(system) #2