# Not Exists OR term match

**URL:** <https://discuss.elastic.co/t/not-exists-or-term-match/118691>\
**Category:** Elasticsearch\
**Created:** [February 6, 2018, 5:21pm UTC](https://discuss.elastic.co/t/not-exists-or-term-match/118691 "2018-02-06T17:21:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dlalex83](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@dlalex83](https://discuss.elastic.co/u/dlalex83)\
**Post date:** [February 6, 2018, 5:21pm UTC](https://discuss.elastic.co/t/not-exists-or-term-match/118691/1 "2018-02-06T17:21:03Z")

</div>

Hi there,

I have an index where all docs up to yesterday don't have a field called "environment" and all the docs from today onward will have an "environment" field set.

I'd like to write a query that returns all the docs with either the "environment" field missing OR the "environment" field set to a specific value ("live").

I've tried combining the must\_not/exist with a term query but I didn't manage to find a solution for it.

Any help?

Thanks

---

<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:** [March 6, 2018, 5:21pm UTC](https://discuss.elastic.co/t/not-exists-or-term-match/118691/2 "2018-03-06T17:21:09Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
