【问题标题】:ElasticSearch Modified Analyzer not working [Stopwords]ElasticSearch Modified Analyzer 不工作 [停用词]
【发布时间】:2013-09-30 09:33:44
【问题描述】:

我将以下内容添加到我的 elasticsearch.yml

# Index Settings
index:
  analysis:
    analyzer:
      # set standard analyzer with no stop words as the default for both indexing and searching
      default:
        type: standard
        stopwords: _none_

现在我做了以下事情:

curl -XGET 'localhost:9200/_analyze?analyzer=default' -d 'this is a test'

还是得到了:

{
  "tokens": [
    {
      "token": "test",
      "start_offset": 10,
      "end_offset": 14,
      "type": "<ALPHANUM>",
      "position": 4
    }
  ]
}

我希望所有的词都在里面!并不是说我通过以下方式运行 elasticsearch:

sudo /usr/local/elasticsearch/elasticsearch-0.90.0/bin/service/elasticsearch64 restart

【问题讨论】:

    标签: elasticsearch stop-words


    【解决方案1】:

    试试这个设置,(代替none,在停用词部分使用空字符串)

    # Index Settings
    index:
      analysis:
        analyzer:
          # set standard analyzer with no stop words as the default for both indexing and searching
          default:
            type: custom
            tokenizer: standard
            filter: [standard,lowercase]
    

    请注意,进行此更改后,您需要重新启动 elasticsearch 服务。

    【讨论】:

    • sudo /usr/local/elasticsearch/elasticsearch-0.90.0/bin/service/elasticsearch64 restart 停止 ElasticSearch... 停止 ElasticSearch。正在启动 ElasticSearch... 等待 ElasticSearch... 正在运行:PID:14633 [ec2-user@ip-10-169-4-9 config]$ curl -XGET 'localhost:9200/_analyze?analyzer=default' -d '这是一个测试' {"tokens":[{"token":"test","start_offset":10,"end_offset":14,"type":"","position":4 }]}[ec2-user@ip-10-169-4-9 配置]$
    • 对不起,在这种情况下,分析器类型必须是自定义的(如果您想更改默认行为)。您可以在那里指定所需的标记器和过滤器。请参阅我编辑的答案。在过滤器中,停止已被移除。默认标准分析器带有标准、小写和停止过滤器。
    猜你喜欢
    • 1970-01-01
    • 2018-10-08
    • 2013-07-28
    • 1970-01-01
    • 2013-09-06
    • 2019-01-19
    • 2020-08-02
    • 2018-12-19
    • 1970-01-01
    相关资源
    最近更新 更多