问题描述
我正在开发一个需要我第一次使用Solr的应用程序.我已经设置好了,为正确的数据建立索引,并根据自己的意愿进行查询,但是我不能似乎使拼写检查组件正常工作.无论我查询什么,拼写检查器都不会返回任何建议.我已经包括了solrconfig和schema.xml的相关部分.
I am working on an application that requires me to use Solr for the first time. I got it set up, indexing the correct data, and querying as I would like it, but I cannot seem to get the spellcheck component working properly. No matter what I query, the spellchecker will not return any suggestions. I have included the relevant parts of my solrconfig and schema.xml.
schema.xml
<fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
<analyzer type="index">
<charFilter class="solr.HTMLStripCharFilterFactory"/>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StandardFilterFactory"/>
</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="stopwords.txt"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StandardFilterFactory"/>
</analyzer>
</fieldType>
<!-- CUT -->
<field name="spell" type="textSpell" indexed="true" stored="true" />
solrconfig.xml
<requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
<str name="defType">edismax</str>
<str name="spellcheck.dictionary">default</str>
<str name="spellcheck.onlyMorePopular">false</str>
<!-- <str name="spellcheck.extendedResults">false</str> -->
<str name="spellcheck.count">3</str>
<str name="qf">
frontlist_flapcopy^0.5 title^2.0 subtitle^1.0 series^1.5 author^3.0 frontlist_ean^6.0
</str>
<str name="pf">
frontlist_flapcopy^0.5 title^2.0 subtitle^1.0 series^1.5 author^3.0 frontlist_ean^6.0
</str>
<str name="fl">
title,subtitle,series,author,eans,formats,prices,frontlist_ean,onsaledate,imprint,frontlist_flapcopy
</str>
<str name="mm">
2<-1 5<-2 6<90%
</str>
<int name="ps">100</int>
<bool name="hl">true</bool>
<str name="q.alt">*:*</str>
<str name="hl.fl">title,subtitle,series,author,frontlist_flapcopy</str>
<str name="f.title.hl.fragsize">0</str>
<str name="f.title.hl.alternateField">title</str>
<str name="f.subtitle.hl.fragsize">0</str>
<str name="f.subtitle.hl.alternateField">url</str>
<str name="f.series.hl.fragsize">0</str>
<str name="f.series.hl.alternateField">url</str>
<str name="f.author.hl.fragsize">0</str>
<str name="f.author.hl.alternateField">url</str>
<str name="f.frontlist_flapcopy.hl.fragsize">0</str>
<str name="f.frontlist_flapcopy.hl.alternateField">url</str>
<str name="echoParams">explicit</str>
<float name="accuracy">0.7</float>
</lst>
<lst name="appends">
<str name="fq">forsaleinusa:true</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>
<!-- CUT -->
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<lst name="spellchecker">
<str name="name">default</str>
<str name="classname">solr.IndexBasedSpellChecker</str>
<str name="field">spell</str>
<str name="spellcheckIndexDir">/path/to/my/spell/index</str>
<str name="accuracy">0.7</str>
<float name="thresholdTokenFrequency">.0001</float>
</lst>
<lst name="spellchecker">
<str name="name">jarowinkler</str>
<str name="classname">solr.IndexBasedSpellChecker</str>
<str name="field">spell</str>
<str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
<str name="spellcheckIndexDir">/path/to/my/spell/index</str>
</lst>
<str name="queryAnalyzerFieldType">textSpell</str>
</searchComponent>
当我转到http://localhost:8983/solr/select/?q=query&spellcheck.build=true
时,查看在/path/to/my/spell/index中生成的文件,有一个segments.gen和segments_1,它们都只包含几个字节的二进制数据.然后,当我输入查询并将&spellcheck=true
附加到查询字符串时,无论查询如何,我都会得到 no 建议:
When I go to http://localhost:8983/solr/select/?q=query&spellcheck.build=true
then look at the files generated in /path/to/my/spell/index, there is a segments.gen and a segments_1, both of which contain only a few bytes of binary data. Then, when I enter a query and append &spellcheck=true
to the query string, I get no suggestions, no matter my query:
<lst name="spellcheck">
<lst name="suggestions"/>
</lst>
有什么想法吗?
推荐答案
我不久前解决了这个问题,但回想起来,问题是我正在使用多个<copyField/>
指令将数据复制到拼写"字段,但是我没有在该字段上设置multiValued="true"
.当我将拼写检查字段设为多值时,它就像一个符咒一样工作!
I ended up resolving this issue a while ago, but to my recollection, the issue was that I was using multiple <copyField/>
directives to copy data to the "spell" field, but I did not set multiValued="true"
on that field. When I made the spellcheck field multivalued, it worked like a charm!
这篇关于Solr拼写检查器未返回任何结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!