3
我有一個查詢,我無法完全回答最相關的答案。在搜索結果開始時使用匹配搜索詞,而不是在搜索結果中使用elasticsearch
如果我搜索 'HERP' 的結果是
- 福HERP
- HERP DERP
- 酒吧HERP
- HERP AA
優選謹以此順序
- HERP AA
- HERP DERP
- 酒吧HERP
- 福HERP
所以我有問題,我想的是:我如何條款中的單詞序列的開始獲得更高比一個看起來更接近尾聲的得分?
我用一下這樣的分析:
"analyzer":[
"autocomplete":[
"type":"custom",
"tokenizer":"standard",
"filter":[
"standard",
"lowercase",
"stop",
"edgeNGramAlpha"
]
],
"filter":[
"edgeNGramAlpha":[
"type":"edgeNGram",
"min_gram":1,
"max_gram":20
]
]
]
和映射看起來像這樣(場的魯特但阿拉看起來是一樣的)
"name": [
"type": "multi_field",
"fields" : [
"untouched": [
"type": "string",
"index": "not_analyzed"
],
"name": [
"type": "string"
],
"autocomplete": [
"analyzer":"${language}_autocomplete",
"type":"string",
]
]
]
和查詢這個樣子的:
{
"from": 0,
"size": 10,
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "herp",
"fields": [
"name^8",
"name.autocomplete^4",
"historic_name.autocomplete"
],
"type": "cross_fields",
"operator": "AND",
"analyzer": "standard"
}
}
}
}
}