我可以自定义弹性搜索以使用我自己的停止词列表吗?

时间:2011-02-07 22:54:33

标签: lucene stop-words elasticsearch

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

4 个答案:

答案 0 :(得分:17)

默认情况下,分析器elasticsearch使用的是带有默认Lucene英语停用词的standard analyzer。我已经将elasticsearch配置为使用相同的分析器但没有停用词,只需将以下内容添加到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_

答案 1 :(得分:4)

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

有关如何更改分析仪设置,请参阅config docs

答案 2 :(得分:4)

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

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

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

答案 3 :(得分:0)

当然可以。使用stopwords_path insead of stopwords。了解更多信息http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-stop-analyzer.html