elasticsearch,Lucene,Stop Words,elasticsearch" /> elasticsearch,Lucene,Stop Words,elasticsearch" />

Lucene 我可以自定义Elastic Search以使用我自己的停止词列表吗?

Lucene 我可以自定义Elastic Search以使用我自己的停止词列表吗?,lucene,stop-words,elasticsearch,Lucene,Stop Words,elasticsearch,具体来说,我想索引所有内容(例如who),没有停止词列表。弹性搜索是否足够灵活且易于更改?是的,您可以使用弹性搜索的内部配置YAML文件进行更改 有关如何更改analyzer设置的信息,请参阅。默认情况下,analyzer elasticsearch使用的是带有默认Lucene English stopwords的。通过向elasticsearch.yml文件添加以下内容,我已将elasticsearch配置为使用相同的分析器,但不使用stopwords # Index Settings ind

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

是的,您可以使用弹性搜索的内部配置YAML文件进行更改


有关如何更改analyzer设置的信息,请参阅。

默认情况下,analyzer elasticsearch使用的是带有默认Lucene English stopwords的。通过向elasticsearch.yml文件添加以下内容,我已将elasticsearch配置为使用相同的分析器,但不使用stopwords

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

通过将以下行添加到elasticsearch.yml中,您可以全局覆盖默认分析器并关闭stopword过滤器:

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

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

当然可以。使用stopwords\u路径插入stopwords。更多信息

这实际上是我对这个问题的最佳答案,因为它删除了stopword过滤器,从而使代码更加紧凑。