Elasticsearch如果同义词是多词,同义词标记过滤器如何工作?

问题描述 投票:1回答:1

有人可以解释我,如果同义词是多词表达而令牌化器是空格,同义词令牌过滤器如何工作?例如。如果我有这个简单的映射

PUT /test_index
{
    "settings": {
        "index" : {
            "analysis" : {
                "analyzer" : {
                    "synonym" : {
                        "tokenizer" : "whitespace",
                        "filter" : ["synonym"]
                    }
                },
                "filter" : {
                    "synonym_graph" : {
                        "type" : "synonym",
                        "lenient": true,
                        "synonyms" : ["multi word, bar => baz"]
                    }
                }
            }
        }
    }
}

我不理解如果空白标记器将术语分解为两个单词多重和单词,如何评估术语多个单词。因此,据我所知,同义词过滤器永远不会将“ multi word”作为在配置中查找同义词的一个术语。任何帮助表示赞赏。

elasticsearch filter synonym
1个回答
0
投票

答案可以在本节中找到

https://www.elastic.co/guide/en/elasticsearch/reference/7.6/token-graphs.html

和此博客文章

http://blog.mikemccandless.com/2012/04/lucenes-tokenstreams-are-actually.html

某些令牌过滤器可以添加跨多个位置的令牌。这些可以包括用于多词同义词的令牌,例如使用“ atm”作为“自动柜员机”的同义词。但是,只有某些令牌过滤器(称为图形令牌过滤器)才能准确记录多位置令牌的positionLength。

索引将忽略positionLength属性,并且不支持包含多位置标记的标记图。但是,诸如match或match_phrase查询之类的查询可以使用这些图从单个查询字符串生成多个子查询。

The following token filters can add tokens that span multiple positions but only record a default positionLength of 1:

- synonym
- word_delimiter

This means these filters will produce invalid token graphs for streams containing such tokens.

Avoid using invalid token graphs for search. Invalid graphs can cause unexpected search results.
© www.soinside.com 2019 - 2024. All rights reserved.