Terms filter with wildcard (search also when the field is nested)


#1

Hi,

I'm looking for help about the terms filter. I have currently a query that works as wanted. The results are correct.
However, I would like to know if this could be simplified:

        filter: {
          or: [
            {
              terms: {
                'blue_content': [false, with_blue]
              }
            },
            {
              terms: {
                'medias.blue_content': [false, with_blue]
              }
            },
            {
              terms: {
                'mediographies.media.blue_content': [false, with_blue]
              }
            },
            {
              not: {
                filter: {
                  exists: {
                    field: '*blue_content'
                  }
                }
              }
            }
          ]
        }

The not filter works with the wildcard, but I couldn't make the terms filter work with it. I have some objects that have the blue_content field directly on the object root, but it can also be nested.

Could I simplify this filter ?

Thank you

Florian


(system) #2