我想操縱我在彈性搜索上進行搜索時得到的分數。 我已經使用boost選項,但它不會給我我想要的結果。經過一些閱讀後,我認爲function_score查詢是解決我的問題。 我明白它是如何工作的,但我無法弄清楚如何改變我當前的查詢來將它與function_score查詢結合使用。在elasticsearch中操縱分數
"query": {
"filtered": {
"query": {
"bool": {
"should": [{
"multi_match": {
"type": "most_fields",
"query": "paus",
"operator": "and",
"boost": 2,
"fields": [
"fullname^2",
"fullname.folded",
"alias^2",
"name^2"
],
"fuzziness": 0
}
}, {
"multi_match": {
"type": "most_fields",
"query": "paus",
"operator": "and",
"boost": 1.9,
"fields": [
"taggings.tag.name^1.9",
"function",
"relations.master.name^1.9",
"relations.master.first_name^1.9",
"relations.master.last_name^1.9",
"relations.slave.name^1.9",
"relations.slave.first_name^1.9",
"relations.slave.last_name^1.9"
],
"fuzziness": 0
}
}, {
"multi_match": {
"type": "most_fields",
"query": "paus",
"operator": "and",
"fields": [
"fullname",
"alias",
"name"
],
"boost": 0.2,
"fuzziness": 1
}
}, {
"match": {
"extra": {
"query": "paus",
"fuzziness": 0,
"boost": 0.1
}
}
}]
}
},
"filter": {
"bool": {
"must": [
{
"terms": {
"type": ["Person"]
}
},
{
"term": {
"deleted": false
}
}
]
}
}
}
正如你所看到的,我們有四種匹配。
- 升壓2:當有上的名字完全匹配
- 加速1.9:當對引用的Tagging是準確的匹配
- 加速0.2:當有在名稱但寫錯了一個字匹配
- 提升0.1:當有額外的(說明)字段
我現在面臨的問題是,有一個字符比賽寫的不對,沒有標註的比賽成績比用火柴更高正確的標記和整個單詞寫錯了。這應該是其他方式...
任何幫助,將不勝感激:)