I am trying to sort by two fields, one date field, the other a whole field. I checked that the fields are correctly matched and that the values ββfor all indexed documents have the correct data types, however every time I try to sort by a numeric field, the ES returns an exception [java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (encoded value really int?)].
The strangest thing is that it returns the results, and they seem to be sorted correctly, so I'm not quite sure what this effect is, but I know that I should not have errors in the answer.
Here is the mapping:
{
"blcdt.products": {
"mappings": {
"review_143758": {
"properties": {
"date_reviewed": {
"type": "date",
"format": "YYYY-MM-dd"
},
"description": {
"type": "string"
},
"manufacturer": {
"type": "string",
"index": "not_analyzed"
},
"model_number": {
"type": "string",
"boost": 2,
"index": "not_analyzed",
"norms": {
"enabled": true
}
},
"msrp": {
"type": "float"
},
"product": {
"type": "string"
},
"product_name": {
"type": "string",
"boost": 2,
"fields": {
"full": {
"type": "string",
"boost": 4,
"index": "not_analyzed",
"norms": {
"enabled": true
}
}
}
},
"product_type": {
"type": "string",
"index": "not_analyzed"
},
"review_category": {
"type": "string",
"index": "not_analyzed"
},
"review_title": {
"type": "string"
},
"review_type": {
"type": "string",
"index": "not_analyzed"
},
"review_type_priority": {
"type": "integer"
},
"score": {
"type": "float"
},
}
}
}
}
}
Here is the query that throws the exception:
POST /blcdt.products/review_143758/_search?pretty=true
{
"query": {
"filtered": {
"filter": [
{
"term": {
"review_category": "Game Reviews"
}
}
]
}
},
"from": 0,
"size": 8,
"sort": [
{
"review_type_priority": {
"order": "desc"
}
},
{
"date_reviewed": {
"order": "desc"
}
}
],
"fields": [
"review_title",
"review_type",
"score"
]
}
and here is a short answer from ES:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 1,
"failed": 4,
"failures": [
{
"index": "blcdt.products",
"shard": 2,
"status": 500,
"reason": "QueryPhaseExecutionException[[blcdt.products][2]: query[filtered(ConstantScore(cache(review_category:Game Reviews)))->cache(_type:review_143758)],from[0],size[8],sort[<custom:\"review_type_priority\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@44ecbc5>!,<custom:\"date_reviewed\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@5123f4b8>!]: Query Failed [Failed to execute main 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?)]; "
},
{
"index": "blcdt.products",
"shard": 3,
"status": 500,
"reason": "QueryPhaseExecutionException[[blcdt.products][3]: query[filtered(ConstantScore(cache(review_category:Game Reviews)))->cache(_type:review_143758)],from[0],size[8],sort[<custom:\"review_type_priority\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@281d24cc>!,<custom:\"date_reviewed\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@115ae1a7>!]: Query Failed [Failed to execute main 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?)]; "
},
{
"index": "blcdt.products",
"shard": 4,
"status": 500,
"reason": "QueryPhaseExecutionException[[blcdt.products][4]: query[filtered(ConstantScore(cache(review_category:Game Reviews)))->cache(_type:review_143758)],from[0],size[8],sort[<custom:\"review_type_priority\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@41238b2a>!,<custom:\"date_reviewed\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@48593cf>!]: Query Failed [Failed to execute main 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?)]; "
},
{
"index": "blcdt.products",
"shard": 0,
"status": 500,
"reason": "QueryPhaseExecutionException[[blcdt.products][0]: query[filtered(ConstantScore(cache(review_category:Game Reviews)))->cache(_type:review_143758)],from[0],size[8],sort[<custom:\"review_type_priority\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@1cbd767c>!,<custom:\"date_reviewed\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@5aadd5a1>!]: Query Failed [Failed to execute main 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?)]; "
}
]
},
"hits": {
"total": 41,
"max_score": null,
"hits": [
{
"_index": "blcdt.products",
"_type": "review_143758",
"_id": "599606",
"_score": null,
"fields": {
"score": [
8
],
"review_type": [
"review"
],
"review_title": [
"Entwined review"
]
},
"sort": [
100,
1403648392
]
},
...
{
"_index": "blcdt.products",
"_type": "review_143758",
"_id": "452429",
"_score": null,
"fields": {
"score": [
9
],
"review_type": [
"review"
],
"review_title": [
"Dark Souls II review"
]
},
"sort": [
100,
1394840094
]
}
]
}
}