Ajay Takur
Ajay Takur

Reputation: 6236

What is the alternative of filter context missing clause in elastic search 8.9?

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"
                    }
                }
            ]
           }
          }
        }

  

Upvotes: 0

Views: 38

Answers (2)

Ajay Takur
Ajay Takur

Reputation: 6236

{
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "must_not": [
              {
                "exists": {
                  "field": "lst_act_date"
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Even with filter/bool/must_not/exists works.

Upvotes: 0

Val
Val

Reputation: 217474

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"
          }
        }
      ]
    }
  }
}

Upvotes: 0

Related Questions