# Simple\_query\_string check if field exists

**URL:** https://discuss.elastic.co/t/simple-query-string-check-if-field-exists/196106
**Category:** Elasticsearch
**Created:** [August 21, 2019, 12:17pm UTC](https://discuss.elastic.co/t/simple-query-string-check-if-field-exists/196106 "2019-08-21T12:17:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ennui](https://avatars.discourse-cdn.com/v4/letter/e/df705f/32.png) [@Ennui](https://discuss.elastic.co/u/Ennui)
#### Post date: [August 21, 2019, 12:17pm UTC](https://discuss.elastic.co/t/simple-query-string-check-if-field-exists/196106/1 "2019-08-21T12:17:41Z")

</div>

Hi,

How would I use simple\_query\_string to check if a field exists? For example, say if I had the following documents

PUT test\_index/\_doc/1  
{  
"user" : "test",  
"message" : "a"  
}

PUT test\_index/\_doc/2  
{  
"user" : "test",  
"message" : "b"  
}

PUT test\_index/\_doc/3  
{  
"user" : "test",  
"message" : "c"  
}

PUT test\_index/\_doc/4  
{  
"user" : "test"  
}

How do I query for documents where (message = "a" OR "b") OR (message field doesn't exist). The query should return documents 1, 2 and 4. I realise this is trivial with

"must\_not": {  
"exists": {  
"field": "message"  
}  
}

but I need to perform this with simple\_query\_string.

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [August 21, 2019, 2:00pm UTC](https://discuss.elastic.co/t/simple-query-string-check-if-field-exists/196106/2 "2019-08-21T14:00:23Z")

</div>

the query string query supports `_exists_:` as a syntax, but the simple query string does not IIRC.

---

<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: [September 18, 2019, 2:00pm UTC](https://discuss.elastic.co/t/simple-query-string-check-if-field-exists/196106/3 "2019-09-18T14:00:26Z")

</div>

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