Hi,
My query
{
"query": {
"bool": {
"must": [
{ "terms": { "status": ["publish", "sold", "sold_by_merchant"] } },
{ "match": { "type": "sale" } },
{ "match": { "manufactureYear": 2021 } },
{
"bool": {
"should": [
{
"multi_match": {
"query": "*toyota Avensis 2021*",
"type": "phrase_prefix",
"fields": ["textSearch", "attributesSearch"]
}
},
{
"match": { "textSearch": { "query": "*toyota Avensis 2021*" } }
},
{
"match": {
"attributesSearch": { "query": "*toyota Avensis 2021*" }
}
}
]
}
}
]
}
},
"from": 0,
"size": 5,
"sort": ["_score", {"price":{"order":"desc"}}]
}
and here my result hits:
{
"took": 4,
"timed_out": false,
"_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 },
"hits": {
"total": { "value": 6, "relation": "eq" },
"max_score": null,
"hits": [
{
"_index": "my_index",
"_id": "3500",
"_score": 17.454771,
"_source": {
"id": 3500,
"textSearch": "តូយ៉ូតាAvensisToyotaAvensis丰田Avensis តូយ៉ូតា Avensis Toyota Avensis 丰田 Avensis",
"price": 31000,
"publicCoverImage": "https://carz-public-cover-stg.s3.ap-southeast-1.amazonaws.com/cars/images/1683703092800-oJpIun",
"attributesSearch": "ឡានមួយទឹក Used 二手"
},
"sort": [17.454771, 31000]
},
{
"_index": "my_index",
"_id": "3435",
"_score": 17.454771,
"_source": {
"id": 3435,
"textSearch": "តូយ៉ូតាAvensisToyotaAvensis丰田Avensis តូយ៉ូតា Avensis Toyota Avensis 丰田 Avensis",
"price": 25000,
"attributesSearch": "ចង្កឹះលេខអូតូ Automatic 自动 ម៉ាស៊ូត Diesel 柴油机 Sedan Sedan 轿车 ក្រហម Red 红色 ឡានមួយទឹក Used 二手"
},
"sort": [17.454771, 25000]
},
{
"_index": "my_index",
"_id": "6941",
"_score": 6.08157,
"_source": {
"id": 6941,
"textSearch": "តូយ៉ូតាVenzaToyotaVenza丰田威飒 តូយ៉ូតា Venza Toyota Venza 丰田 威飒",
"price": 230,
"attributesSearch": "ឡានមួយទឹក Used 二手"
},
"sort": [6.08157, 230]
},
{
"_index": "my_index",
"_id": "5011",
"_score": 5.859531,
"_source": {
"id": 5011,
"textSearch": "តូយ៉ូតាអាល់ហ្វាToyotaAlphard丰田埃尔法 តូយ៉ូតា អាល់ហ្វា Toyota Alphard 丰田 埃尔法",
"price": 9999,
"attributesSearch": "ថ្មី New 新"
},
"sort": [5.859531, 9999]
},
{
"_index": "my_index",
"_id": "4137",
"_score": 5.859531,
"_source": {
"id": 4137,
"textSearch": "តូយ៉ូតាកាមរីToyotaCamry丰田凯美瑞 តូយ៉ូតា កាមរី Toyota Camry 丰田 凯美瑞",
"price": 2000,
"attributesSearch": "ថ្មី New 新"
},
"sort": [5.859531, 2000]
},
{
"_index": "my_index",
"_id": "7830",
"_score": 5.859531,
"_source": {
"id": 7830,
"textSearch": "តូយ៉ូតាបែលតាToyotaBelta丰田贝尔塔 តូយ៉ូតា បែលតា Toyota Belta 丰田 贝尔塔",
"price": 555,
"attributesSearch": "ចង្កឹះលេខដៃ Manual 手动 Hybrid Hybrid 混合动力汽车 Sedan Sedan 轿车 ប្រផេះ Gray 灰色 ឡានមួយទឹក Used 二手",
},
"sort": [5.859531, 555]
}
]
}
}
My expected result is sort by price from low to high.
I tried leaving "_score" out of my query. Sort by price is correct but results by keyword are no longer correct.
Elasticsearch v8.7.0
Looking forward to hearing from everyone soon.