0

I'm having docs containning nested list

fixed_fields: [
    {
       id: 12,
       value: "someValue"
    },
    {
       id: 38,
       value: "someValue2"
    },
]

Now I need to find all documents that don't have fixed field with id = 38

I've tried:

            "bool":{
              "must":[
                {
                  "nested":{
                    "path":"fixed_fields",
                    "filter":{
                      "bool":{
                        "must_not":[
                          {
                            "term":{
                              "fixed_fields.id":38
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              ]
            }

But I got all documents having any fixed_fields in response, including the ones with id 38.

I'm using elastic in version 2.4.6, and I don't have option to upgrade it

1 Answer 1

3

Try this instead:

{
 "bool": {
    "must_not": [{
        "nested": {
            "path": "fixed_fields",
            "filter": {
                "term": {
                    "fixed_fields.id": 38
                }
            }
        }
    }]
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.