【问题标题】:Can I customize Elastic Search to use my own Stop Word list?我可以自定义 Elastic Search 以使用我自己的停用词列表吗?
【发布时间】:2011-06-23 02:15:16
【问题描述】:

具体来说,我想为没有停用词列表的所有内容(例如谁)编制索引。弹性搜索是否足够灵活且易于更改?

【问题讨论】:

    标签: lucene stop-words elasticsearch


    【解决方案1】:

    是的,您可以使用 ElasticSearch 的内部配置 YAML 文件来执行此操作。

    请参阅config docs,了解如何更改分析仪设置。

    【讨论】:

      【解决方案2】:

      默认情况下,elasticsearch 使用的分析器是 standard analyzer,带有默认的 Lucene 英语停用词。通过将以下内容添加到 elasticsearch.yml 文件,我已将 elasticsearch 配置为使用相同的分析器但没有停用词。

      # 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_
      

      【讨论】:

        【解决方案3】:

        您可以通过将这些行添加到您的 elasticsearch.yml 中来全局覆盖默认分析器并关闭停用词过滤器

        index.analysis.analyzer.default:
          type: custom
          tokenizer: standard
          filter: standard, lowercase
        

        这将创建一个带有标准标记器和两个过滤器的自定义分析器:标准和小写。这样,您的自定义分析器将与标准分析器相同,但不会使用停用词过滤器。因为它被命名为“默认”,所以 elasticsearch 将在没有明确设置分析器的任何地方使用它。

        【讨论】:

        • 这实际上是我看到的这个问题的最佳答案,因为它删除了停用词过滤器,从而使代码更紧凑。
        【解决方案4】:

        当然可以。使用 stopwords_path 代替停用词。更多信息http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-stop-analyzer.html

        【讨论】:

          猜你喜欢
          • 2023-02-15
          • 2018-10-17
          • 2011-02-20
          • 2012-07-31
          • 2016-08-22
          • 2012-02-27
          • 1970-01-01
          • 2022-07-12
          • 1970-01-01
          相关资源
          最近更新 更多