# Query field doesn't exist or have a special value

**URL:** <https://discuss.elastic.co/t/query-field-doesnt-exist-or-have-a-special-value/206065>\
**Category:** Elasticsearch\
**Created:** [October 31, 2019, 3:00pm UTC](https://discuss.elastic.co/t/query-field-doesnt-exist-or-have-a-special-value/206065 "2019-10-31T15:00:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fetch](https://avatars.discourse-cdn.com/v4/letter/f/dbc845/32.png) [@fetch](https://discuss.elastic.co/u/fetch)\
**Post date:** [October 31, 2019, 3:00pm UTC](https://discuss.elastic.co/t/query-field-doesnt-exist-or-have-a-special-value/206065/1 "2019-10-31T15:00:52Z")

</div>

Hello,

I'm using ELK 6.8.2.

I have a set of data where the field "system" can either have a value or doesn't exist at all.

The queries `NOT _exists_: system` and `system: value` works fine. However, as soon as I try to combine them at a single query `NOT _exists_: system OR system: value`, ES returns 0 results.

What's wrong with the query and how can I get the desired results?

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [November 4, 2019, 9:07pm UTC](https://discuss.elastic.co/t/query-field-doesnt-exist-or-have-a-special-value/206065/2 "2019-11-04T21:07:40Z")

</div>

When using multiple boolean operators, it's a good idea to use parentheses as these operators do not honor the usual precedence rules. Try writing your query like this:

```auto
(NOT _exists_: system) OR (system: value)

```

---

<div class="post-metadata">

**Author:** ![fetch](https://avatars.discourse-cdn.com/v4/letter/f/dbc845/32.png) [@fetch](https://discuss.elastic.co/u/fetch)\
**Post date:** [November 15, 2019, 5:47am UTC](https://discuss.elastic.co/t/query-field-doesnt-exist-or-have-a-special-value/206065/3 "2019-11-15T05:47:56Z")

</div>

Thanks, it works!

---

<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:** [December 13, 2019, 5:51am UTC](https://discuss.elastic.co/t/query-field-doesnt-exist-or-have-a-special-value/206065/4 "2019-12-13T05:51:52Z")

</div>

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