0
字的正確排序評分結果,我們有一個elasticsearch指數具有以下配置:在elasticsearch
PUT phonebook
{
"settings":{
"index":{
"number_of_shards":8,
"number_of_replicas":1
}
},
"mappings":{
"person":{
"_all":{
"enabled":false
},
"_source":{
"enabled":true
},
"properties":{
"id":{
"type":"long"
},
"name":{
"type":"text",
"index_options":"positions"
},
"number":{
"type":"long"
}
}
}
}
}
它基本上與數十億條記錄一個巨大的電話簿。我在尋找這個指數用下面的查詢:
GET /contacts/contact/_search
{
"size":0,
"query":{
"match":{
"name":{
"fuzziness":1,
"query":"george bush",
"operator":"and"
}
}
},
"aggs":{
"by_number":{
"terms":{
"field":"number",
"size":10,
"order":{
"max_score":"desc"
}
},
"aggs":{
"max_score":{
"max":{
"script":"_score"
}
},
"sample":{
"top_hits":{
"size":1
}
}
}
}
}
}
結果由現場「數量」和最佳匹配分組爲每個號碼這種方式返回。但我需要的是根據結果中單詞順序的正確性對結果進行自定義評分/排序。 因此,對於「喬治布什」的詢問,「喬治布什」總是比「布什喬治」更好。 match_phrase搜索並不適合我,因爲我在搜索時使用了模糊處理。