很少有 Solr 停用词出现在分面搜索结果中

Few Solr stopwords showing up in facet search results

问题:很少有 Solr 停用词出现在分面搜索结果中。

当前实施: 我在 stopwords.txt 文件中至少有 30 到 40 个停用词。 Solr facet search 与停用词完美配合,例如:

for the, is, and, as

但像

这样的停用词很少

call, state,ask

出现在分面搜索结果中。我尝试使用 solr 分析。词出现在 ST。

我正在使用以下配置

<field name="message" type="text_en" indexed="true" stored="true" 
multiValued="true"/>

<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" 
            words="lang/stopwords_en.txt"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.KeywordMarkerFilterFactory" 
            protected="protwords.txt"/>
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"       
            ignoreCase="true" expand="true"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true"   
            words="lang/stopwords_en.txt"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.KeywordMarkerFilterFactory" 
            protected="protwords.txt"/>
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>
</fieldType>

尝试更改过滤器的顺序。将 StopFilterFactory 放在链的最后。这应该可以防止停用词被索引。

<field name="message" type="text_en" indexed="true" stored="true" 
multiValued="true"/>

<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.KeywordMarkerFilterFactory" 
            protected="protwords.txt"/>
    <filter class="solr.PorterStemFilterFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" 
            words="lang/stopwords_en.txt"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"       
            ignoreCase="true" expand="true"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.KeywordMarkerFilterFactory" 
            protected="protwords.txt"/>
    <filter class="solr.PorterStemFilterFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true"   
            words="lang/stopwords_en.txt"/>
  </analyzer>
</fieldType>

说明

前一个 tokenizer/filter 的输出作为输入提供给下一个 tokenizer/filter。

来自 Solr Reference Guide

Filters examine a stream of tokens and keep them, transform or discard them, or create new ones. Tokenizers and filters may be combined to form pipelines, or chains, where the output of one is input to the next. Such a sequence of tokenizers and filters is called an analyzer and the resulting output of an analyzer is used to match query results or build indices.

因此,如果您有一个像 "calling" 这样的词,它将首先到达您的字段类型链中的 StopFilterFactory

由于 "calling" 在您的 stopwords.txt 文件中没有一个词,它将转到 PorterStemFilterFactory,其中 "calling" 更改为 "call"。

检查此 website 以查看使用 PorterStemFilterFactory 的词根)并索引该词。

这就是您仍然在索引中看到停用词的原因。

根据您使用的 Solr 版本,您可能会看到 "calling" 这样的词是如何被索引的。

http://YourSolrIPAddress:8983/solr/#/YourCoreORCollection/schema-browser?field=message