2014年8月5日 星期二

[Elasticsearch] NumberFormatException / Invalid shift value in prefixCoded bytes



Elasticsearch NumberFormatException

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?)]

在使用 Elasticsearch 做 aggregation , facet ,或者是 sort 時,相同名稱的 field 有不一樣的 data types 在同一個index內就會發生這樣的 exception。
所有的types 在 Elasticsearch 底層操作中都會被轉成 Lucene Document的形式,這樣構成了 elasticsearch的typeless 特點。

總結一句,就是在對同一個index做需要把欄位的值拿出來轉換時,發生了 NumberFormatException,可能是index內該欄位的資料 type 並不相同,也無法轉型成功。

所以,當發生這樣的問題時,請先確認index內該欄位的資料是否都是同樣的type。


補上 shay.banon 的說明

Sep 20, 2010; 3:19am Re: Number Format Exception?
kimchy
Administrator
6275 posts
Ahh, yes, this is a limitation in elasticsearch. Basically, all types are broken down into Lucene Documents, with their "typeness" added by elasticsearch. The limit to that is the fact that a field with the same name across different types *within the same index* must be of the same type (long/integer/string). The problem does not exists between indices.

Sorry about that!,
-shay.banon

ElasticSearch Users - Number Format Exception?
http://elasticsearch-users.115913.n3.nabble.com/Number-Format-Exception-td1474946.html

cf.
peicheng-note: elasticsearch 相關 elasticsearch文章
http://peichengnote.blogspot.tw/search/label/elasticsearch
peicheng note: [elasticsearch] 關於 brain split / cluster split 成兩個 clusters
peicheng note: [elasticsearch] 再談 _all field
http://peichengnote.blogspot.tw/2014/06/elasticsearch-all-field.html
peicheng note: [elasticsearch]range query depends on the field type
http://peichengnote.blogspot.tw/2014/06/elasticsearchrange-query-depends-on.htmlpeicheng-note: [elasticsearch] document id _id field uuid
http://peichengnote.blogspot.tw/2014/05/elasticsearch-document-id-id-field-uuid.html
peicheng-note: [elasticsearch/logstash] logstash id 自動產生 document id "_id" automatic id generation
http://peichengnote.blogspot.tw/2014/04/elasticsearchlogstash-logstash-id.html
peicheng note: [elasticsearch] index size , shard size , heap size design
http://peichengnote.blogspot.tw/2014/07/elasticsearch-index-size-shard-size.html

沒有留言:

張貼留言