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

**URL:** <https://discuss.elastic.co/t/terms-filter-with-wildcard-search-also-when-the-field-is-nested/37646>\
**Category:** Elasticsearch\
**Created:** [December 20, 2015, 3:21pm UTC](https://discuss.elastic.co/t/terms-filter-with-wildcard-search-also-when-the-field-is-nested/37646 "2015-12-20T15:21:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nyddogghr](https://avatars.discourse-cdn.com/v4/letter/n/b487fb/32.png) [@nyddogghr](https://discuss.elastic.co/u/nyddogghr)\
**Post date:** [December 20, 2015, 3:21pm UTC](https://discuss.elastic.co/t/terms-filter-with-wildcard-search-also-when-the-field-is-nested/37646/1 "2015-12-20T15:21:42Z")

</div>

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:

```auto
        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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:29pm UTC](https://discuss.elastic.co/t/terms-filter-with-wildcard-search-also-when-the-field-is-nested/37646/2 "2017-07-05T23:29:36Z")

</div>

Closed on July 5, 2017, 11:29pm UTC


