elasticsearch - 如何从弹性搜索中的默认_english_停用词列表中删除停用词?
问题描述
我正在使用默认的英语停用词过滤文本。我发现'and'是英文的停用词,但我需要搜索包含'and'的结果。我只想and
从这个默认的英语停用词过滤器中删除单词并像往常一样使用其他停用词。我的 elasticsearch 架构如下所示。
"settings": {
"analysis": {
"analyzer": {
"default": {
"tokenizer": "whitespace" ,
"filter": ["stop_english"]
}
}....,
"filter":{
"stop_english": {
"type": "stop",
"stopwords": "_english_"
}
}
我希望看到包含AND
带有 _search api 的单词的文档。
解决方案
您可以像这样手动设置给定索引的停用词:
PUT /my_index
{
"settings": {
"analysis": {
"filter": {
"my_stop": {
"type": "stop",
"stopwords": ["and", "is", "the"]
}
}
}
}
}
我还在这里找到了 elasticsearch 使用的英语停用词列表。如果您设法在索引中手动设置相同的停用词列表减去“and”,并在新配置的索引中使用良好的停用词重新索引您的数据,那么您应该很高兴!
关于数据的重新索引,您应该查看reindex api。我认为这是必需的,因为数据的标记化发生在摄取时,因此您需要通过重新索引来重做摄取。在更改索引设置或某些映射更改时需要大部分时间(不是 100% 肯定,但我认为这是有道理的)。
推荐阅读
- c - tcp 客户端如何理解服务器状态码
- arduino - 重置命令和拍照命令有问题
- javascript - 当我去下个月时,日历中缺少几个月
- javascript - 使用 php sdk 显示 Facebook 登录按钮
- java - 找不到密钥库文件
- performance - 在 Angular 6+ 应用程序中检测慢速互联网
- go - 在 Ubuntu 16.04 中出现 GOPATH 错误“go: cannot use path@version syntax in GOPATH mode”
- python - 如何将具有多个键值的字典数组转换为具有单个键值的字典?
- php - 为什么我的 SAW(简单加法加权)无法显示结果?
- java - JPA Criteria API:遍历列表并创建谓词