【发布时间】:2011-06-23 02:15:16
【问题描述】:
具体来说,我想为没有停用词列表的所有内容(例如谁)编制索引。弹性搜索是否足够灵活且易于更改?
【问题讨论】:
标签: lucene stop-words elasticsearch
具体来说,我想为没有停用词列表的所有内容(例如谁)编制索引。弹性搜索是否足够灵活且易于更改?
【问题讨论】:
标签: lucene stop-words elasticsearch
是的,您可以使用 ElasticSearch 的内部配置 YAML 文件来执行此操作。
请参阅config docs,了解如何更改分析仪设置。
【讨论】:
默认情况下,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_
【讨论】:
您可以通过将这些行添加到您的 elasticsearch.yml 中来全局覆盖默认分析器并关闭停用词过滤器:
index.analysis.analyzer.default:
type: custom
tokenizer: standard
filter: standard, lowercase
这将创建一个带有标准标记器和两个过滤器的自定义分析器:标准和小写。这样,您的自定义分析器将与标准分析器相同,但不会使用停用词过滤器。因为它被命名为“默认”,所以 elasticsearch 将在没有明确设置分析器的任何地方使用它。
【讨论】:
当然可以。使用 stopwords_path 代替停用词。更多信息http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-stop-analyzer.html
【讨论】: