我为Drupal网站配置了Solr搜索服务器。我正在运行带有Solr 3.6的Java 1.7(我不能使用更新的版本,因为Drupal模块还不支持Solr 4)。
我启用了ngram,以便搜索部分单词。当我在“polisvoorwaarden”这个词中搜索“polis”时,突出显示效果很好。但是当我搜索“polisvoo”时它失败了。起初我以为这将是某种奇怪的长度限制。但后来我搜索“voorwaa”它的工作,但“voorwaar”不起作用。 “voorwaar”比“polisvoo”更长。
我有拼写字段的以下架构设置:
<fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory" />
<charFilter class="solr.HTMLStripCharFilterFactory" />
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.LengthFilterFactory" min="4" max="25" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.RemoveDuplicatesTokenFilterFactory" />
<filter class="solr.NGramFilterFactory" minGramSize="4" maxGramSize="25" />
</analyzer>
</fieldType>
以下在solrconfig中突出显示的设置:
<requestHandler name="dismax" class="solr.SearchHandler" default="true">
<lst name="defaults">
<str name="defType">dismax</str>
<str name="echoParams">none</str>
<float name="tie">0.01</float>
<str name="fl">item_id,score </str>
<int name="ps">100</int>
<str name="q.alt">*:*</str>
<!-- Highlighting parameters -->
<str name="hl">true</str>
<str name="hl.fl">spell</str>
<str name="hl.simple.pre">[HIGHLIGHT]</str>
<str name="hl.simple.post">[/HIGHLIGHT]</str>
<str name="hl.snippets">1</str>
<str name="hl.fragsize">275</str>
<str name="hl.mergeContiguous">true</str>
<!-- By default don't spell check. -->
<str name="spellcheck">false</str>
<!-- Defaults for the spell checker when used. -->
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.extendedResults">false</str>
<!-- The number of suggestions to return. -->
<str name="spellcheck.count">1</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>