0

The same syntax below has been working in 2.3 v and if I do execute it in 8.9v does not work.

{
    "size": 0,
    "query": {
    "bool": {
    "filter": [
                {
                    "missing": { //"reason": "unknown field [missing]"
                        "field": "lst_act_date"
                    }
                }
            ]
           }
          }
        }

  
Val
  • 207,596
  • 13
  • 358
  • 360
Ajay Takur
  • 6,079
  • 5
  • 39
  • 55

2 Answers2

0

The missing query has been deprecated in ES 2.2.0. You now need to use the bool/must_not/exists combo:

{
  "size": 0,
  "query": {
    "bool": {
      "must_not": [
        {
          "exists": {
            "field": "lst_act_date"
          }
        }
      ]
    }
  }
}
Val
  • 207,596
  • 13
  • 358
  • 360
0
{
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "must_not": [
              {
                "exists": {
                  "field": "lst_act_date"
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Even with filter/bool/must_not/exists works.

Ajay Takur
  • 6,079
  • 5
  • 39
  • 55
  • 1
    What do you mean by "Even with filter/bool/must_not/exists works." ? Works or doesn't? – Val Aug 22 '23 at 13:37
  • can we write it the other way also as I mentioned? – Ajay Takur Aug 22 '23 at 15:26
  • it works, but it makes no sense to add a must_not inside a filter... [must_not already executes in the filter context](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html#filter-context), which is what my answer refers to – Val Aug 22 '23 at 15:28
  • 1
    Got it will stick with your direction. – Ajay Takur Aug 22 '23 at 15:36