在 ElasticSearch 中呈现部分匹配之前,我需要对确切的字符串匹配进行排序
假设我有三个文件:
- 迈克尔一个
- 迈克尔·B
- 米查
如果我搜索micha,它只会返回第三个文档。但是,如果我搜索micha*,我会按照上面列出的顺序获得所有三个文档。
我的问题是,如何让第三个文档(完全匹配)出现在其他结果之前?
:analysis => {
:filter => {
"my_edge_ngram_filter" => {
"type" => "edgeNGram",
"min_gram" => 1,
"max_gram" => 128,
"side" => "front",
},
"my_phone_filter" => {
"type" => "pattern_replace",
"pattern" => "\\D",
"replacement" => ""
}
},
:analyzer => {
"default_index" => {
"tokenizer" => "uax_url_email",
"filter" => [
"standard",
"lowercase",
"stop",
"my_edge_ngram_filter"
],
"type" => "custom"
},
"my_phone_analyzer" => {
"tokenizer" => "keyword",
"filter" => [
"my_phone_filter",
],
"type" => "custom"
},
"default_search" => {
"type" => "standard"
}
}
}
}