0

I am upgrading to elasticsearch 5.2 and have the following query, which now fails because the "missing" filter is deprecated:

{
    "query": {
      "bool": {
        "should": [
          {
            "missing": {
              "field": "birthday"
            }
          },
          {
           "range": {
             "birthday": {
               "lte": "20131231"
             }
           }
          }
        ]
      }
    }
  }

So, I am looking for documents that are either missing the birthday field or have a birthday less than 12/31/2013. The suggested replacement for "missing" is to use "must_not". I get that but how do I now do the same "or" query I had going on before? I have:

{
  "query": {
    "bool": {
      "should": {
        "range": {
          "birthday": {
            "lte": "20131231"
          }
        }
      },
      "must_not": {
        "exists": {
          "field": "birthday"
        }
      }
    }
  }
}

1 Answers1

0

You're on the right path and almost there:

{
  "query": {
    "bool": {
      "should": [
        {
          "range": {
            "birthday": {
              "lte": "20131231"
            }
          }
        },
        {
          "bool": {
            "must_not": {
              "exists": {
                "field": "birthday"
              }
            }
          }
        }
      ]
    }
  }
}
Val
  • 207,596
  • 13
  • 358
  • 360