Solr 不建议内部带点的名称

Solr doesn't suggest names with dot inside

我在使用 solr 的建议条款时遇到了一些问题。

我已将标题编入索引,例如。 "foo.a123", "foo.a456"... 如果搜索 "foo" Solr returns me foo 作为建议,但如果我搜索 "foo.a" 则没有给出任何建议。如果我搜索,建议会正常工作 "foo a".

我正在使用以下配置:

<fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
        <analyzer type="index">
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>

            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.SynonymFilterFactory" synonyms="english/synonyms.txt" ignoreCase="true" expand="true"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="english/stopwords.txt"/>
            <filter class="solr.StandardFilterFactory" />
            <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.WhitespaceTokenizerFactory" />

            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="english/stopwords.txt"/>
            <filter class="solr.StandardFilterFactory" />
            <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
        </analyzer>
    </fieldType>

提交的 'spell' 正在使用 textSpell 配置

<field name="spell" type="textSpell" indexed="true" stored="false" multiValued="true"/>
<copyField source="title" dest="spell"/>
<copyField source="subTitle" dest="spell"/>
<copyField source="content" dest="spell"/>

'spell' 字段用作 facet.field,而本例中的 facet.prefix 将是 'foo.a'

"facet_counts": {
"facet_queries": {},
"facet_fields": {
  "spell": []
},
"facet_dates": {},
"facet_ranges": {}
}

在此先感谢您的帮助。

只需使用 wordDelimiter 过滤器 https://lucene.apache.org/core/4_4_0/analyzers-common/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilter.html

 <filter class="solr.WordDelimiterFilterFactory" types="wdfftypes.txt" generateNumberParts="0" stemEnglishPossessive="0" splitOnCaseChange="1" preserveOriginal="1" catenateAll="1" catenateWords="1" catenateNumbers="1" generateWordParts="1" splitOnNumerics="1"/>

solr.StandardFilterFactory

This filter is no longer operational in Solr when the luceneMatchVersion (in solrconfig.xml) is higher than "3.1".

在 Solr 4.10.4 中有 <luceneMatchVersion>4.10.4</luceneMatchVersion>

所以更改查询分析器中的过滤器

搞清楚了,配置工作如上所示。 wordDelimeter 也可以,但对我的情况来说不是必需的。 (StandardFilterFactory 什么都不做。)

我完全误解了配置文件中的 stored="false" 选项。我期望不需要将文档重新写入索引的行为,但实际上标志定义了是否可以在搜索结果中检索到该文件。因此我只需要重新索引所有文档。

感谢您的帮助!