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>
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>
Any idea what is going on here?
I had a very similar problem that I was never able to resolve. Someone posted a detailed answer on my question that may be able to help you out:
solr suggester not returning any results
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With