gpt4 book ai didi

Elasticsearch:edgeNGram 标记过滤器是否适用于非英语标记?

转载 作者:行者123 更新时间:2023-12-02 22:12:45 25 4
gpt4 key购买 nike

我正在尝试为索引设置一个新的映射。它将支持由 ES 提供支持的部分关键字搜索和自动完成请求。

带有空白标记器的 edgeNGram 标记过滤器似乎是一种可行的方法。到目前为止,我的设置看起来像这样:

curl -XPUT 'localhost:9200/test_ngram_2?pretty' -H 'Content-Type: application/json' -d'{
"settings": {
"index": {
"analysis": {
"analyzer": {
"customNgram": {
"type": "custom",
"tokenizer": "whitespace",
"filter": ["lowercase", "customNgram"]
}
},
"filter": {
"customNgram": {
"type": "edgeNGram",
"min_gram": "3",
"max_gram": "18",
"side": "front"
}
}
}
}
}
}'

问题出在日语单词上! NGrams 是否适用于日文字母?例如:【11月13日13时まで、フォロー&RTで応募!】

此处没有空格 - 无法使用部分关键字搜索文档,这是预期的吗?

最佳答案

您可能想看看 icu_tokenizer,它增加了对外语的支持 https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-icu-tokenizer.html

Tokenizes text into words on word boundaries, as defined in UAX #29: Unicode Text Segmentation. It behaves much like the standard tokenizer, but adds better support for some Asian languages by using a dictionary-based approach to identify words in Thai, Lao, Chinese, Japanese, and Korean, and using custom rules to break Myanmar and Khmer text into syllables.

放置 icu_sample

{
"settings": {
"index": {
"analysis": {
"analyzer": {
"my_icu_analyzer": {
"tokenizer": "icu_tokenizer"
}
}
}
}
}
}

请注意,要在您的索引中使用它,您需要安装适当的插件:

bin/elasticsearch-plugin install analysis-icu

将此添加到您的代码中:

curl -XPUT 'localhost:9200/test_ngram_2?pretty' -H 'Content-Type: application/json' -d'{
"settings": {
"index": {
"analysis": {
"analyzer": {
"customNgram": {
"type": "custom",
"tokenizer": "icu_tokenizer",
"filter": ["lowercase", "customNgram"]
}
},
"filter": {
"customNgram": {
"type": "edgeNGram",
"min_gram": "3",
"max_gram": "18",
"side": "front"
}
}
}
}
}
}'

通常您会使用 standard 分析器搜索这样的自动完成,而不是使用 icu_tokenizer(但不是 edgeNGram 过滤器)并在搜索时将其应用于您的查询,或者将其明确设置为您将 customNgram 应用到的字段的 search_analyzer

关于Elasticsearch:edgeNGram 标记过滤器是否适用于非英语标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47327956/

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