gpt4 book ai didi

elasticsearch - Elasticsearch:如何限制Snowball Analyzer

转载 作者:行者123 更新时间:2023-12-03 02:06:56 33 4
gpt4 key购买 nike

使用雪球分析仪,当我查询“房屋”时会得到“房屋”的结果。我需要分析器进行大多数搜索,但是在这种情况下,返回值是无关紧要的。我将如何限制分析仪应对这些情况的工作?

最佳答案

您可以通过keyword_marker和stem_exclusion过滤器执行此操作:

Preventing stemming

The stem_exclusion parameter for language analyzers (see Configuring language analyzers) allowed us to specify a list of words that should not be stemmed. Internally, these language analyzers use the keyword_marker token filter to mark the listed words as keywords, which prevents subsequent stemming token filters from touching those words.



http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/controlling-stemming.html

Specifying keywords in a file

While the language analyzers only allow us to specify an array of words in the stem_exclusion parameter, the keyword_marker token filter also accepts a keywords_path parameter which allows us to store all of our keywords in a file. The file should contain one word per line, and must be present on every node in the cluster. See Updating stopwords for tips on how to update this file.



此示例(来自文档)显示了如何实现此目的:
PUT /my_index
{
"settings": {
"analysis": {
"filter": {
"no_stem": {
"type": "keyword_marker",
"keywords": [ "skies" ]
}
},
"analyzer": {
"my_english": {
"tokenizer": "standard",
"filter": [
"lowercase",
"no_stem",
"porter_stem"
]
}
}
}
}
}

具体情况将因您现有的分析仪设置而异,但这可以助您一臂之力。

关于elasticsearch - Elasticsearch:如何限制Snowball Analyzer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24998462/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com