Monat: März 2016

Elasticsearch NumberFormatException

Some time ago I came across a really annoying error in Elasticsearch.
The error log was something like this:

SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[_9x6xIKhTXK7y_jqC92YIQ][index][0]: ElasticicsearchException[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?)]; }

It was driving me nuts to find out what the exact problem was. I searched several hours in the internet for an answer until I found a helpful post in a forum.
The actual problem is that there is a field in your Elasticsearch index, which have different mapping settings in different types.
I.e. you have the type car and the type driver and both are types of the index company. Both tpes have an ID. But one is declare as integer value and the other is a string.
Elasticsearch doesn’t make a difference between fields in different types but with the same name in the same index. So check your mappings to solve the problem.

But be aware. After I changed my mappings I still got the error message. After changing the values I also needed to clear my index to delete all old documents.
For deleting all old cached documents I made an optimize POST request to elasticsearch:

http://elasticsearch:9200/[index]/_optimize?max_num_segments=1&wait_for_merge=false/

The params are really important otherwise the documents will not be deleted. After that everything worked fine again.

I hope I could help you with my post and save you some valuable time of research:)

Starting my first blog

Hey out there. My name is Stefanie and I’ve been working as a PHP / fullstack developer for more than 3 years now.

Recently I read an article about best practices for improving my developing skills.

One of the recommendations was to write a blog about developing problems which comes up in the daily business. So I decided to follow this approach and startet to write a blog. In this blog I want to give you some practical helps and share my knowledge I’ve gained the last years as fullstack developer.

Have fun and don’t hesitate to leave me a comment.

Regards Stefanie