How to replace "and" operator inside "must_not" to group clauses. Query migration to ES 7.6.1

Hi guys, I'm trying to migrate following query to ES 7.6.1, but not sure how to replace "and" functionality cause it looks like it's not longer supported in ES 7.6.1.

...
  "must_not": [
    {
      "and": [
        {
          "term": {
            "status": "complete"
          }
        },
        {
          "range": {
            "startDate": {
              "lte": "2021-12-19"
            }
          }
        }
      ]
    },
    {
      "and": [
        {
          "term": {
            "status": "complete"
          }
        },
        {
          "range": {
            "updatedTs": {
              "lte": 1670881333350
            }
          }
        }
      ]
    }
  ]
...

Hi @aanaya

If you and AND behavior try use bool + must

{
  "query": {
    "bool": {
      "must_not": [
        {
          "bool": {
            "must": [
              {
                "term": {
                  "status": "complete"
                }
              },
              {
                "range": {
                  "startDate": {
                    "lte": "2021-12-19"
                  }
                }
              }
            ]
          }
        },
        {
          "bool": {
            "must": [
              {
                "term": {
                  "status": "complete"
                }
              },
              {
                "range": {
                  "updatedTs": {
                    "lte": 1670881333350
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}
1 Like

FWIW 7.6 is EOL and no longer supported, you should be upgrading to 7.17 at the very latest.

1 Like

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