1

ElasticSearch 使用“名称”的多字段索引我的业务文档,以便我可以加权不同程度的名称匹配(精确匹配、多个单词之一等)。这是我的映射中的一个片段

"name" : {

                "type" : "multi_field",
                "fields": {
                    "name":          {"type" : "string", "store" : "yes", "index_analyzer"  : "AutoCompleteIndexAnalyzer",   "search_analyzer" : "AutoCompleteSearchAnalyzer"},
                    "exact_match":   {"type" : "string", "store" : "yes", "index_analyzer"  : "ExactMatchNameIndexAnalyzer", "search_analyzer" : "ExactMatchNameSearchAnalyzer"},
                    "auto_name":     {"type" : "string", "store" : "yes", "index_analyzer"  : "keyword",                     "search_analyzer" : "keyword"},
                 }
            },

因为它是一个多字段,所以我只提供一次值——ES 只是多次分析它。

所以我完全不知道“完整”子字段如何获得完全不正确的值,而“名称”子字段是正确的。我不明白为什么完全匹配不起作用,所以我编写了一个脚本字段来在搜索结果中给我“exact_match”标记:

"exact_match_tokenized_name": [
            "santininewyorkstyledeli"
        ],
"name": "Sal NY Pizza",
"name.auto_name": "Sal NY Pizza"

如果有人对此有任何想法,我将不胜感激。

谢谢!

4

0 回答 0