【发布时间】:2020-06-17 17:06:08
【问题描述】:
我有一个包含道路名称的索引。我的设置如下所示:
"settings": {
"max_ngram_diff": 20,
"analysis": {
"analyzer": {
"str_search_analyzer": {
"type": "custom",
"tokenizer": "whitespace",
"filter": [
"lowercase"
]
},
"str_index_analyzer": {
"type": "custom",
"tokenizer": "whitespace",
"filter": [
"lowercase",
"substring"
]
}
},
"filter": {
"substring": {
"type": "edgeNGram",
"min_gram": 1,
"max_gram": 255
}
}
}
}
}
在索引中我有这样的字符串:
- 酒吧路
- 巴富路
- 富路
所以当我搜索“Foo”时,我会得到 #2 和 #3 作为命中。这是意料之中的。
但我想控制点击的顺序。在这种情况下,我希望 #3 作为第一个命中,因为字符串以搜索词开头。
是否可以根据需要对匹配进行排序?
【问题讨论】:
标签: elasticsearch elasticsearch-query