Or operator in expression

Hi guys,

I'm trying to convert the following expression to a elasticseach query.

Field 1 != X or Field 2 != Y

Can you help me translate this to elasticsearch?

Thank you very much

DELETE test

PUT test/doc/_bulk?refresh=true
{"index": {"_id": "1"}}
{"field1": "X","field2": "Y"}
{"index": {"_id": "2"}}
{"field1": "A","field2": "Y"}
{"index": {"_id": "3"}}
{"field1": "X","field2": "B"}
{"index": {"_id": "5"}}
{"field1": "A","field2": "B"}

GET test/doc/_search
{
  "query": {
    "bool": {
      "must_not": [
        {
          "bool": {
            "must": [
              {
                "match": {
                  "field1": "X"
                }
              },
              {
                "match": {
                  "field2": "Y"
                }
              }
            ]
          }
        }
      ]
    }
  }
}
1 Like

It worked.

Thank you very much for the help.

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