# Generic Exists and Condition for Empty String for Numbers and Strings

**URL:** <https://discuss.elastic.co/t/generic-exists-and-condition-for-empty-string-for-numbers-and-strings/42752>\
**Category:** Elasticsearch\
**Created:** [February 25, 2016, 5:21pm UTC](https://discuss.elastic.co/t/generic-exists-and-condition-for-empty-string-for-numbers-and-strings/42752 "2016-02-25T17:21:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elm/32/3782_2.png) [@elm](https://discuss.elastic.co/u/elm)\
**Post date:** [February 25, 2016, 5:21pm UTC](https://discuss.elastic.co/t/generic-exists-and-condition-for-empty-string-for-numbers-and-strings/42752/1 "2016-02-25T17:21:27Z")

</div>

The Exists filter at ES is also returning true for empty strings. This is for us not intended behaviour, so we simple make an and condition that combines these two. However, this is not generic as for number fields it does not work becauer the query validation fails as the term query for not equals "" is not a number. We can put the logic based on the field definition in our query, but is there maybe an option to make ES to accept a string for a number field as a term query? Or another trick to get this behavior from a filter?

---

<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:13pm UTC](https://discuss.elastic.co/t/generic-exists-and-condition-for-empty-string-for-numbers-and-strings/42752/2 "2017-07-05T23:13:40Z")

</div>


