【发布时间】:2016-11-07 11:15:56
【问题描述】:
我正在尝试在 Solr 中进行拼写检查,但遇到了大小写问题。问题是更改查询的大小写不会影响返回的结果数量,但会更改拼写检查结果。例如,如果我输入“leave”,那么我会得到 7 个文档结果并且没有拼写检查结果。但如果我搜索“离开”,我仍然会得到 7 个文档结果,但现在拼写检查有这些结果:
"spellcheck":{
"suggestions":[
"Leave",{
"numFound":3,
"startOffset":0,
"endOffset":5,
"origFreq":0,
"suggestion":[{
"word":"leave",
"freq":7},
{
"word":"lease",
"freq":4},
{
"word":"travel",
"freq":2}]}],
"correctlySpelled":true,
"collations":[
"collation",{
"collationQuery":"leave",
"hits":7,
"misspellingsAndCorrections":[
"Leave","leave"]}]}
建议小写'leave'。请注意,它仍然说“正确拼写”是真的。这是我的 schema.xml 中的字段和字段类型:
<field name="title" type="text_en" indexed="true" stored="true" multiValued="false" />
<field name="filename" type="string" indexed="true" stored="true" multiValued="false" />
<field name="filext" type="string" indexed="true" stored="true" multiValued="false" />
<field name="version" type="int" indexed="false" stored="true" multiValued="false" />
<field name="docSet" type="string" indexed="true" stored="true" multiValued="false" />
<field name="businessArea" type="string" indexed="true" stored="true" multiValued="false" />
<field name="processGroup" type="string" indexed="true" stored="true" multiValued="false" />
<field name="applicability" type="string" indexed="true" stored="true" multiValued="true" />
<field name="content" type="text_en" indexed="true" stored="true" multiValued="false" />
<field name="lastIndex" type="int" indexed="true" stored="true" multiValued="false" />
<field name="popularity" type="int" indexed="true" stored="true" multiValued="false" default="1"/>
<field name="speller" type="speller_type" indexed="true" stored="true" multiValued="true" />
<copyField source="*" dest="speller"/>
<fieldType name="speller_type" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords_en.txt"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords_en.txt"/>
</analyzer>
</fieldType>
这是我的 solrconfig.xml 的拼写检查部分:
<requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
...
<!--****************************************************************
* Spellcheck configuration
*****************************************************************-->
<str name="spellcheck">on</str>
<!-- Suggestions -->
<str name="spellcheck.count">10</str>
<!-- <str name="spellcheck.maxResultsForSuggest">10</str> -->
<str name="spellcheck.extendedResults">true</str>
<!-- Collations -->
<str name="spellcheck.collate">true</str>
<str name="spellcheck.maxCollationTries">5</str>
<str name="spellcheck.collateExtendedResults">true</str>
<str name="spellcheck.collateMaxCollectDocs">0</str>
...
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<lst name="spellchecker">
<str name="classname">solr.IndexBasedSpellChecker</str>
<str name="spellcheckIndexDir">./spellchecker</str>
<str name="field">speller</str>
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
如果我对拼写器字段应用小写过滤器,那么为什么在搜索时更改大小写会更改拼写检查器的结果?我已经为此寻找解决方案,但找不到任何解决方法。
感谢您的帮助。
编辑:我遇到了与停用词相同的问题,它们没有被应用。尽管“for”是 stopwords.txt 中的停用词,并且我正在应用到拼写器 fieldType,但如果我输入“leave for application”,它会建议“leave form application”作为排序规则查询。为什么停用词没有被删除?
【问题讨论】:
标签: solr filter schema spell-checking lowercase