Good afternoon. I have a problem with sorting: When I obtain the hits, they aren't sorted correctly, and every hit has a 'sort' field that normally would have as value, the value of the field im sorting with, but its not the case. I will show my mapping and query and a sample of my results.Please let me know if you need any other information.
MAPPING:
{
"index_name" : {
"mappings" : {
"typeA" : {
"dynamic" : "strict",
"properties" : {
"id_offer" : {
"type" : "long"
},
"id_product" : {
"type" : "long"
},
"id_view_product_price" : {
"type" : "long"
},
"offer_price" : {
"type" : "double"
},
"price" : {
"type" : "double"
}
}
}
}
}
}
QUERY:
curl -XGET 'http://127.0.0.1:9200/index_name/typeA/_search?pretty' -d '
{
"query":{
"filtered":{
"query":{
"match_all":[
]
},
"filter":{
"exists":{
"field":"offer_price"
}
}
}
},
"sort":[
{
"offer_price":"desc"
}
],
"size":20
}'
QUERY RESPONSE:
{
"took" : 35,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2552,
"max_score" : null,
"hits" : [ {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "31046",
"_score" : null,
"_source":{"id_view_product_price":"31046","id_product":"7206","id_offer":"14","price":"5999.0000","offer_price":5999},
"sort" : [ "P\u0003\u00017" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "30029",
"_score" : null,
"_source":{"id_view_product_price":"30029","id_product":"8375","id_offer":"6","price":"9999.0000","offer_price":5000},
"sort" : [ "P\u0003\u00013" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "27643",
"_score" : null,
"_source":{"id_view_product_price":"27643","id_product":"6691","id_offer":"14","price":"4999.0000","offer_price":4999},
"sort" : [ "P\u0003\u00013" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "31048",
"_score" : null,
"_source":{"id_view_product_price":"31048","id_product":"6900","id_offer":"14","price":"4099.0000","offer_price":4099},
"sort" : [ "P\u0003\u00010" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "27629",
"_score" : null,
"_source":{"id_view_product_price":"27629","id_product":"6637","id_offer":"14","price":"4099.0000","offer_price":4099},
"sort" : [ "P\u0003\u00010" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "27590",
"_score" : null,
"_source":{"id_view_product_price":"27590","id_product":"6555","id_offer":"14","price":"3999.0000","offer_price":3999},
"sort" : [ "P\u0003\u0001/" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "33605",
"_score" : null,
"_source":{"id_view_product_price":"33605","id_product":"8167","id_offer":"52","price":"4499.0000","offer_price":3600},
"sort" : [ "P\u0003\u0001," ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "31047",
"_score" : null,
"_source":{"id_view_product_price":"31047","id_product":"6899","id_offer":"14","price":"3499.0000","offer_price":3499},
"sort" : [ "P\u0003\u0001+" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "30449",
"_score" : null,
"_source":{"id_view_product_price":"30449","id_product":"5535","id_offer":"15","price":"2990.0000","offer_price":2990},
"sort" : [ "P\u0003\u0001'" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "27264",
"_score" : null,
"_source":{"id_view_product_price":"27264","id_product":"5533","id_offer":"14","price":"2990.0000","offer_price":2990},
"sort" : [ "P\u0003\u0001'" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "27373",
"_score" : null,
"_source":{"id_view_product_price":"27373","id_product":"5948","id_offer":"14","price":"2999.0000","offer_price":2999},
"sort" : [ "P\u0003\u0001'" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "29161",
"_score" : null,
"_source":{"id_view_product_price":"29161","id_product":"4117","id_offer":"14","price":"2409.0000","offer_price":2409},
"sort" : [ "P\u0003\u0001\"" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "30532",
"_score" : null,
"_source":{"id_view_product_price":"30532","id_product":"5697","id_offer":"15","price":"2299.0000","offer_price":2299},
"sort" : [ "P\u0003\u0001!" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "27147",
"_score" : null,
"_source":{"id_view_product_price":"27147","id_product":"4909","id_offer":"14","price":"2299.0000","offer_price":2299},
"sort" : [ "P\u0003\u0001!" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "27128",
"_score" : null,
"_source":{"id_view_product_price":"27128","id_product":"4778","id_offer":"14","price":"2219.0000","offer_price":2219},
"sort" : [ "P\u0003\u0001!" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "27123",
"_score" : null,
"_source":{"id_view_product_price":"27123","id_product":"4746","id_offer":"14","price":"2199.0000","offer_price":2199},
"sort" : [ "P\u0003\u0001!" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "28918",
"_score" : null,
"_source":{"id_view_product_price":"28918","id_product":"3790","id_offer":"14","price":"2259.0000","offer_price":2259},
"sort" : [ "P\u0003\u0001!" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "27181",
"_score" : null,
"_source":{"id_view_product_price":"27181","id_product":"5115","id_offer":"14","price":"2219.0000","offer_price":2219},
"sort" : [ "P\u0003\u0001!" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "27210",
"_score" : null,
"_source":{"id_view_product_price":"27210","id_product":"5272","id_offer":"14","price":"2209.0000","offer_price":2209},
"sort" : [ "P\u0003\u0001!" ]
}, {
"_index" : "index_name",
"_type" : "typeA",
"_id" : "27666",
"_score" : null,
"_source":{"id_view_product_price":"27666","id_product":"6737","id_offer":"14","price":"1999.0000","offer_price":1999},
"sort" : [ "P\u0003\u0001\u001F" ]
} ]
}
}
At first glance seems that everything sorted correctly, but watch closely at the hits with _id "28918" and "27123", and also please notice the weird value of the "sort" field of every hit. What is wrong here? I will appreciate any help. Thanks in advance.