# Query nullabe fields with value compare

**URL:** <https://discuss.elastic.co/t/query-nullabe-fields-with-value-compare/67947>\
**Category:** Elasticsearch\
**Created:** [December 4, 2016, 12:31pm UTC](https://discuss.elastic.co/t/query-nullabe-fields-with-value-compare/67947 "2016-12-04T12:31:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alonzo](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@alonzo](https://discuss.elastic.co/u/alonzo)\
**Post date:** [December 4, 2016, 12:31pm UTC](https://discuss.elastic.co/t/query-nullabe-fields-with-value-compare/67947/1 "2016-12-04T12:31:06Z")

</div>

Hi,  
I`m trying to query for a field which can be null, the query is for all document which it`s field is not null and the field value is equal for a given string.  
e.g: field named parent can be null or can hold string with the parent name, the query needed is all the documents with parent value (not null - exists) and equal to a given parent name.  
i tried to look in different places on how to do this, and cannot find something exactly like this.

Thanks,  
Alon

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [December 4, 2016, 5:44pm UTC](https://discuss.elastic.co/t/query-nullabe-fields-with-value-compare/67947/2 "2016-12-04T17:44:28Z")

</div>

Can you past part of your query and/or you mapping to see how you write your queries ?

You do not need to add "not null" , just make a termQuery with your\_field = value.

---

<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:** [January 1, 2017, 5:44pm UTC](https://discuss.elastic.co/t/query-nullabe-fields-with-value-compare/67947/3 "2017-01-01T17:44:56Z")

</div>

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