功能提升查詢中排序包含有關於手機的詳細信息的索引,殼體上蓋等我如何elasticsearch
下面是使用的查詢。
{
"query": {
"function_score": {
"query": { "match": {"title" :"Apple iPhone 6s"} },
"boost": "5",
"functions": [
{
"filter": { "match": { "main_category": "mobiles" } },
"weight": 8
},
{
"filter": { "match": {"main_category": "cases-and-covers" } },
"weight": 6
}
],
"max_boost": 8,
"score_mode": "max",
"boost_mode": "multiply",
"min_score" : 5
}
},
"_source":["title","main_category","selling_price"],
"size" : 1000
}
是否有可能通過出售價格升序提高手機類像下面和排序的手機類別中。
Boost工作正常。如何在特定的提升功能內進行排序?
如果用戶搜索蘋果iPhone 6S,我想手機類別被提升和最低價應該是第一位的,然後外殼和蓋類產品也銷售價格升序排列。
下面是需要
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 104,
"max_score": 40.645245,
"hits": [
{
"_index": "test",
"_type": "products",
"_id": "shop_24",
"_score": 40.645245,
"_source": {
"selling_price": 72000,
"main_category": "mobiles",
"title": "Apple iPhone 6s"
}
},
{
"_index": "test",
"_type": "products",
"_id": "shop_20",
"_score": 40.168346,
"_source": {
"selling_price": 82000,
"main_category": "mobiles",
"title": "Apple iPhone 6s Plus"
}
},
{
"_index": "test",
"_type": "products",
"_id": "shop_15",
"_score": 39.365562,
"_source": {
"selling_price": 92000,
"main_category": "mobiles",
"title": "Apple iPhone 6s Plus"
}
},
{
"_index": "test",
"_type": "products",
"_id": "shop_17",
"_score": 39.365562,
"_source": {
"selling_price": 2000,
"main_category": "cases-and-covers",
"title": "Case cover for Apple iPhone 6s"
}
},
{
"_index": "test",
"_type": "products",
"_id": "shop_18",
"_score": 39.365562,
"_source": {
"selling_price": 2300,
"main_category": "cases-and-covers",
"title": "Case cover for Apple iPhone 6s Plus"
}
}
]
}
}
請幫助的結果?
你能展示你想達到的目標嗎? – user3775217
問題已更新。請檢查。 –