# NumberFormatException - how can I filter queries around it?

**URL:** <https://discuss.elastic.co/t/numberformatexception-how-can-i-filter-queries-around-it/2605>\
**Category:** Elasticsearch\
**Created:** [June 12, 2015, 8:11pm UTC](https://discuss.elastic.co/t/numberformatexception-how-can-i-filter-queries-around-it/2605 "2015-06-12T20:11:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ecweaver](https://avatars.discourse-cdn.com/v4/letter/e/e19b73/32.png) [@ecweaver](https://discuss.elastic.co/u/ecweaver)\
**Post date:** [June 12, 2015, 8:11pm UTC](https://discuss.elastic.co/t/numberformatexception-how-can-i-filter-queries-around-it/2605/1 "2015-06-12T20:11:49Z")

</div>

I have a rather large (or at least non-small) logs use-case, with an index per day with many types. Many of those types have a "status" field, some in nested objects and some right at \_source level. I have struggled to rename all the non-integer versions of the fields named "status" to other things (such as "delivery\_status" for mail logs).

One user wants to sort on response.status but it keeps erroring out with the well-known "Number Format Exception [Invalid shift value....]". I have dug through the day's index and found some "status":null entries.

Can anyone tell me whether these are the likely cause of the NumberFormatException, and whether there's any way to do a filtered query around them?  
I have done: curl 'localhost:9200/logs-2015.06.12/sometype/\_search?pretty=1&size=10' -d '{"query":{"filtered":{"filter":{"exists":{"field":"response.status"}}}}' and if I add a sort clause on that field it still fails in that way.

I am adding "default\_value":0 clauses to all the various "status" fields in the template, for future indices, but short of re-indexing past days (and they tend to be in the 1G doc range), I'm hoping a query can be made to handle them.

Thanks for whatever you might be able to tell me.

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [June 14, 2015, 1:21am UTC](https://discuss.elastic.co/t/numberformatexception-how-can-i-filter-queries-around-it/2605/2 "2015-06-14T01:21:40Z")

</div>

maybe try missing values? [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html#\_missing\_values](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html#_missing_values) check out unmapped\_type too.

hth

---

<div class="post-metadata">

**Author:** ![ecweaver](https://avatars.discourse-cdn.com/v4/letter/e/e19b73/32.png) [@ecweaver](https://discuss.elastic.co/u/ecweaver)\
**Post date:** [June 14, 2015, 8:13pm UTC](https://discuss.elastic.co/t/numberformatexception-how-can-i-filter-queries-around-it/2605/3 "2015-06-14T20:13:59Z")

</div>

Thank you for that suggestion!

I put in both missing\_value and unmapped\_type; still getting the error. This is most vexing.

Any clues on how to find what value in what record is fouling the field?

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:** [July 6, 2017, 12:07am UTC](https://discuss.elastic.co/t/numberformatexception-how-can-i-filter-queries-around-it/2605/4 "2017-07-06T00:07:35Z")

</div>


