Recently in an e-commerce project, where there is a strange phenomenon in commodity search, there will be a decrease in the number of items depending on the sort of field. According to the general road or can not be found, or normal display, why the increase in accordance with the sales order will result in a reduction in query results.
Check the ES log found error:nested: numberformatexception[invalid shift value in prefixcoded bytes (is Encoded value really an INT?)
The data type conversion error can be seen, but it is unclear why it is wrong. Help Google. I found the following is the same as my case.
https://github.com/elastic/elasticsearch/issues/9191#issuecomment-77784022
Looking at the index type mapping in the following index to the data structure, it is found that there are instances of different types of the same name field. The problem is solved by removing the wrong index type and maintaining the same structure.
To further confirm, I have written a small example. Make some mistakes first, school using set type mapping before adding data. School2 directly add data, type automatic recognition. The following is the mapping structure of the index type:
{"State":"Open", "settings": {"index.version.created": "901399", "Index.number_of_replicas": "1", "Index.uuid": " qk4pv5isqzm8eb1qcu7b6w "," Index.number_of_shards ":" 5 "}, "mappings":{"School2":{"Properties": {"id": {"type": "String"}, "name":{"Type":"string"}, "Age":{"Type":"Long"}, "studentlist":{"Properties":{"Sex": {"type": "String"}, "StudentID":{"Type":"string"}, "Studentname":{"Type":"string"}}}}, "School":{"Properties":{"id": {"store": True, "analyzer": "Ik", "type": "String"}, "name":{"Store":true, "analyzer": "Ik", "type": "String"}, "Age":{"Store":true, "type": "Integer"}, "studentlist":{"Properties":{"Sex": {"store": True, "analyzer": "Ik", "type": "String"}, "StudentID":{"Store":true, "analyzer": "Ik", "type": "String"}, "Studentname":{"Store":true, "analyzer": "Ik", "type": "String"}}, "type": "Nested"}}}, "aliases": []}
Note the type of the Age field in the index type school and school2 the former is Integer the latter is Long . We followed the full match query and sorted according to age . The problem arose. Here is the result of the error.
{"Error":"searchphaseexecutionexception[failed to execute phase [query], all shards Failed;shardfailures {[ijhim0-hsmkr_uhzfrbfta][demoindex][3]:Remotetransportexception[[node2][inet[/192.168.0.202:9300]][search/phase/query]];nested:queryphaseexecutionexception[[demoindex][3]: query[filtered (Constantscore (*:*))->cache (_type:school2)], From[0],size[20],sort[<custom:\ "age\": Org.elasticse[email protected]32780f73>!]: Query Failed [Failed to Execute main query]];nested:elasticsearchexception[java.lang.numberformatexception:invalid shift value in prefixcoded bytes (is encoded value R Eally 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 (was encoded value really an INT?)]; }{[0p8agoqgss-h4aby0hmi8q][demoindex][4]:Queryphaseexecutionexception[[demoindex][4]: query[filtered (Constantscore (*:*))->cache (_type:school2)], From[0],size[20],sort[<custom:\ "age\": Org.elasticse[email protected]1d42c789>!]: Query Failed [Failed to Execute main query]];nested:elasticsearchexception[java.lang.numberformatexception:invalid shift value in prefixcoded bytes (is encoded value R Eally 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 (was encoded value really an INT?)]; }{[0p8agoqgss-h4aby0hmi8q][demoindex][1]:queryphaseexecutionexception[[demoindex][1]: query[filtered (Constantscore (*:*))->cache (_type:school2)], From[0],size[20],sort[<custom:\ "age\": Org.elasticse[email protected]2998a407>!]: Query Failed [Failed to Execute main query]];nested:elasticsearchexception[java.lang.numberformatexception:invalid shift value in prefixcoded bytes (is encoded value R Eally 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 (was encoded value really an INT?)]; }{[ijhim0-hsmkr_uhzfrbfta][demoindex][2]:Remotetransportexception[[node2][inet[/192.168.0.202:9300]][search/phase/query]];nested:queryphaseexecutionexception[[demoindex][2]: query[filtered (Constantscore (*:*))->cache (_type:school2)], From[0],size[20],sort[<custom:\ "age\": Org.elasticse[email protected]65fde78f>!]: Query Failed [Failed to Execute main query]];nested:elasticsearchexception[java.lang.numberformatexception:invalid shift value in prefixcoded bytes (is encoded value R Eally 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 (was encoded value really an INT?)]; }{[Ijhim0-hsmkr_uhzfrbfta][demoindex][0]:Remotetransportexception[[node2][inet[/192.168.0.202:9300]][search/phase/query]];nested:queryphaseexecutionexception[[demoindex][0]: query[filtered (Constantscore (*:*))->cache (_type:school2)], From[0],size[20],sort[<custom:\ "age\": Org.elasticse[email protected]f6e47a1>!]: Query Failed [Failed to Execute main query]];nested:elasticsearchexception[java.lang.numberformatexception:invalid shift value in prefixcoded bytes (is encoded value R Eally 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 (was encoded value really an INT?)]; }] "," status ":
Elasticsearch Learning problem record--invalid shift value in prefixcoded bytes (was encoded value really an INT?)