【问题标题】:Add extra stop words elasticsearch添加额外的停用词 elasticsearch
【发布时间】:2014-02-03 14:45:50
【问题描述】:

目的

删除停用词出现在术语方面

环境和设置

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 不应被索引也不应出现在令牌中

【问题讨论】:

    标签: elasticsearch stop-words


    【解决方案1】:

    您无需弄乱分析器配置即可从术语方面排除单词。您可以在请求术语方面时为 exclude 参数提供要排除的单词列表:

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

    请参阅terms facet documentation 了解更多信息。

    【讨论】:

      猜你喜欢
      • 2019-05-28
      • 2013-07-28
      • 1970-01-01
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多