我对Solr的拼写检查提出了一个奇怪的问题。
我搜索这样的术语(例如产品编号):08p17a6
使用这个术语,我在索引中找到文档。
我启用了spellcheck = true。所以除了文档之外,solr还在xml响应中给出了一个拼写检查建议:
<lst name="spellcheck">
<lst name="suggestions">
<lst name="p17a6">
<int name="numFound">1</int>
<int name="startOffset">2</int>
<int name="endOffset">7</int>
<arr name="suggestion">
<str>08p17a6</str>
</arr>
</lst>
</lst>
</lst>
Solr取了我的搜索词的第一个数字,并根据“p17a6”给出了一个建议。我不明白为什么他会根据他的建议削减前两个数字。
如果启用spellcheck.collate,事情会变得更加奇怪:
<lst name="spellcheck">
<lst name="suggestions">
<lst name="p17a6">
<int name="numFound">1</int>
<int name="startOffset">2</int>
<int name="endOffset">7</int>
<arr name="suggestion">
<str>08p17a6</str>
</arr>
</lst>
<str name="collation">0808p17a6</str>
</lst>
</lst>
我需要在多个搜索字词上使用spellcheck.collate进行推荐。但正如您所看到的,xml响应建议我使用“0808p17a6”。
有谁知道这是怎么发生的?
编辑:
以下是关于拼写检查的架构配置:
<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" />
复制域的源字段配置如下:
<field name="title" type="text" indexed="true" stored="true" termVectors="true" omitNorms="true" />
<field name="subTitle" type="text" indexed="true" stored="true" termVectors="true" omitNorms="true" />
<field name="content" type="text" indexed="true" stored="true" termVectors="true" />
这是分析器的配置:
<filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1"
generateNumberParts="1"
catenateWords="1"
catenateNumbers="1"
catenateAll="0"
splitOnCaseChange="1"
preserveOriginal="1"
/>
<!-- best practice (currently) for synonyms is to add them by
expansions during index time
-->
<filter class="solr.SynonymFilterFactory" synonyms="german/synonyms.txt" ignoreCase="true" expand="true"/>
<!-- Case insensitive stop word removal.
add enablePositionIncrements=true in both the index and query
analyzers to leave a 'gap' for more accurate phrase queries.
-->
<filter class="solr.StopFilterFactory" words="german/stopwords.txt" ignoreCase="true" enablePositionIncrements="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SnowballPorterFilterFactory" language="German2" protected="german/protwords.txt"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1"
generateNumberParts="1"
catenateWords="0"
catenateNumbers="0"
catenateAll="0"
splitOnCaseChange="1"
preserveOriginal="1"
/>
<filter class="solr.StopFilterFactory" words="german/stopwords.txt" ignoreCase="true" enablePositionIncrements="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SnowballPorterFilterFactory" language="German2" protected="german/protwords.txt"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>
<!-- Setup simple analysis for spell checking -->
<fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="german/synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory" words="german/stopwords.txt" ignoreCase="true"/>
<filter class="solr.StandardFilterFactory" />
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StopFilterFactory" words="german/stopwords.txt" ignoreCase="true"/>
<filter class="solr.StandardFilterFactory" />
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>