gpt4 book ai didi

elasticsearch - 添加额外的停用词elasticsearch

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

目的

删除术语表中出现的停用词

环境和设置

Mac OSX,
通过自制软件安装ES 0.90.7

步骤

更新配置

# /usr/local/Cellar/elasticsearch/0.90.7/config/elasticsearch.yml
# add more Stopwords to default standard analyzer
index:
analysis:
analyzer:
standard:
type: standard
stopwords: [http, t.co]

重新启动ES
curl -XGET 'localhost:9200/_analyze?analyzer=standard&pretty' -d 'this is a test http'

结果是
{
"tokens": [
{
"token": "test",
"start_offset": 10,
"end_offset": 14,
"type": "<ALPHANUM>",
"position": 4
},
{
"token": "http",
"start_offset": 15,
"end_offset": 19,
"type": "<ALPHANUM>",
"position": 5
}
]
}

期望

不应为http编制索引,也不应在 token 中显示

最佳答案

您无需弄混分析器配置即可从术语方面中排除单词。您可以给exclude参数一个单词列表,以在请求术语方面时将其排除在外:

"facets" : {
"body" : {
"terms" : {
"field" : "body",
"exclude" : ["http". "t.co"]
}
}
}

有关更多信息,请参见 terms facet documentation

关于elasticsearch - 添加额外的停用词elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21132224/

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