# 500 "Number format exception" on Terms Aggregation

**URL:** <https://discuss.elastic.co/t/500-number-format-exception-on-terms-aggregation/19514>\
**Category:** Elasticsearch\
**Created:** [August 28, 2014, 4:57pm UTC](https://discuss.elastic.co/t/500-number-format-exception-on-terms-aggregation/19514 "2014-08-28T16:57:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rob\_Schwartzberg](https://avatars.discourse-cdn.com/v4/letter/r/a88e57/32.png) [@Rob\_Schwartzberg](https://discuss.elastic.co/u/Rob_Schwartzberg)\
**Post date:** [August 28, 2014, 4:57pm UTC](https://discuss.elastic.co/t/500-number-format-exception-on-terms-aggregation/19514/1 "2014-08-28T16:57:07Z")

</div>

Hi All,

I'm facing a strange error while running a terms aggregation over what is  
supposed to be a field with type "short".

Error:  
RemoteTransportException[[][search/phase/query]]; nested:  
ElasticsearchException[java.lang.NumberFormatException: Invalid shift value  
in prefixCoded bytes (is encoded value really an INT?)]; nested:  
UncheckedExecutionException[java.lang.NumberFormatException: Invalid shift  
value in prefixCoded bytes (is encoded value really an INT?)]; nested:  
NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded  
value really an INT?)]; }]"

Here is my query.

GET cuevents-2014.35/\_search?search\_type=count  
{  
"query": {  
"term": {  
"event": {  
"value": "unique\_view"  
}  
}  
},  
"aggs": {  
"Site\_name": {  
"terms": {  
"field": "_session\_depth_",  
"size": 10  
}  
}  
}  
}

Here is a mapping of the field that causes the error, against all types in  
the index.

{  
"cuevents-2014.35" : {  
"mappings" : {  
"logs" : {  
"session\_depth" : {  
"full\_name" : "session\_depth",

- 

```
     "mapping":{"session_depth":{"type":"short"}}*
  }
}

```

}  
}  
}

From what I've been able to find online, that error can be thrown if you  
have a field with the same name, in two different types, with different  
definitions, in the same index.

e.g.  
"logs" : {  
"session\_depth" : {  
"type":"_short_"  
}  
}  
"trees" : {  
"session\_depth" : {  
"type":"_string_"  
}  
}

I found that I did in fact have my session\_depth field defined differently  
within two types of the same index. So, I deleted all documents of the  
type that was incorrect. I also performed an optimization on the index,  
hoping it would purge the deleted documents. However, I'm still receiving  
the error above.

Does anyone know if I need to take any additional steps to remove the  
documents marked for deletion, or if something else would cause the 500  
error?

Thanks!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c7eb5386-3c8b-4140-8b42-811f3c8a5feb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c7eb5386-3c8b-4140-8b42-811f3c8a5feb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![fmassot](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@fmassot](https://discuss.elastic.co/u/fmassot)\
**Post date:** [September 21, 2014, 6:20pm UTC](https://discuss.elastic.co/t/500-number-format-exception-on-terms-aggregation/19514/2 "2014-09-21T18:20:01Z")

</div>

Hi,

I had exactly the same issue and was annoyed when I finally understood why it happened.

Anyway, I deleted all the documents containing the wrong type and made an \_optimize?max\_num\_segments=1 and everything works well now 🙂

---

<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, 1:00am UTC](https://discuss.elastic.co/t/500-number-format-exception-on-terms-aggregation/19514/3 "2017-07-06T01:00:52Z")

</div>


