【问题标题】:Elasticsearch standard analyser stopwordsElasticsearch 标准分析器停用词
【发布时间】:2015-08-07 15:15:25
【问题描述】:

我试图猜测 elasticsearch 标准分析器中的默认停用词列表是什么。我运行的是 1.3.1 版本,在我看来使用的是英文列表,因为运行这样的通配符查询

{
      "wildcard" : {
        "name" : {
          "wildcard" : "*in*"
        }
      }
}

不给我任何结果(我肯定有包含“in”的文档名称,并且在使用 not_analyzed 映射时会返回它们)。但是,在1.0 breaking changes 上,他们说默认值现在是空的,Standard Analyzer documentation for the latest version 中也有同样的说明。另一方面,当单击给定链接了解更多详细信息时,我最终会看到Stop Analyzer documentation,表示默认仍然是英文。

有什么帮助吗?谢谢

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    这将是标准分析器的停用词列表:http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-analyzers-common/4.9.0/org/apache/lucene/analysis/core/StopAnalyzer.java?av=f#50

    50   static {
    51     final List<String> stopWords = Arrays.asList(
    52       "a", "an", "and", "are", "as", "at", "be", "but", "by",
    53       "for", "if", "in", "into", "is", "it",
    54       "no", "not", "of", "on", "or", "such",
    55       "that", "the", "their", "then", "there", "these",
    56       "they", "this", "to", "was", "will", "with"
    57     );
    58     final CharArraySet stopSet = new CharArraySet(Version.LUCENE_CURRENT, 
    59         stopWords, false);
    60     ENGLISH_STOP_WORDS_SET = CharArraySet.unmodifiableSet(stopSet); 
    61   }
    

    standard 的 Elasticsearch 源代码:https://github.com/elastic/elasticsearch/blob/v1.3.1/src/main/java/org/elasticsearch/index/analysis/StandardAnalyzerProvider.java#L47

    链接到 Lucene 的 StandardAnalyzer,而后者又引用了 StopAnalyzer 的停用词列表:http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-analyzers-common/4.9.0/org/apache/lucene/analysis/standard/StandardAnalyzer.java?av=f#63

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多