gpt4 book ai didi

elasticsearch - Elastic Search 忽略 `token_chars`

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

我在 Mac 上使用 Elastic Search 1.7.1。

这是我的索引映射:

{
"settings":{
"analysis":{
"filter":{
"my_edgengram":{
"max_gram":15,
"token_chars":[
"letter",
"digit"
],
"type":"edgeNGram",
"min_gram":1
},
},
"analyzer":{
"stop_edgengram_analyzer":{
"filter":[
"lowercase",
"asciifolding",
"stop",
"my_edgengram"
],
"type":"custom",
"tokenizer":"whitespace"
}
}
}
}
}

调试分析器:

$ curl -XGET 'http://localhost:9200/objects/_analyze?analyzer=stop_edgengram_analyzer&text=America,s&pretty=True'
{
"tokens" : [
... skipped ...
, {
"token" : "america",
"start_offset" : 0,
"end_offset" : 9,
"type" : "word",
"position" : 1
}, {
"token" : "america,",
"start_offset" : 0,
"end_offset" : 9,
"type" : "word",
"position" : 1
}, {
"token" : "america,s",
"start_offset" : 0,
"end_offset" : 9,
"type" : "word",
"position" : 1
} ]
}

为什么输出中出现 america,s token ?

, 是标点符号。我希望仅使用 my_edgengram 过滤器的 token_chars 属性中指定的字母和数字。

最佳答案

你很困惑edge_ngram tokenizeredge_ngram token filter .

来自文档:

Tokenizers are used to break a string down into a stream of terms or tokens.

在问题中提供的示例中,whitespace 是正在使用的分词器

另一方面, token 过滤器:

accept a stream of tokens from a tokenizer and can modify tokens (eg lowercasing), delete tokens (eg remove stopwords) or add tokens (eg synonyms).

在 OP egde_ngram 中提供的示例中,正在使用 token 过滤器。

edge_ngram 标记过滤器不支持 token_chars,因此被忽略。

关于elasticsearch - Elastic Search 忽略 `token_chars`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32128858/

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