Hi all, I know this probably seems like an uninteresting problem and smells, even to me, like a stupid/newbie mis-configuration [Yes. I am reading the excellent solr in action and trying my hand at applying the "suggestion examples"], but I looked a bit into this tonight, fired up the debugger, stepped through code, etc to try to find where I erred: to no avail.
Some questions: First, does the SpellCheck component's "FSTLookupFactory" require any extra special configuration, e.g. term vectors for the field ("suggest" below), etc.: <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.FSTLookupFactory</str> <str name="field">suggest</str> Second, why does the FSTCompletionLookup not check for nulls here for these variables: higherWeightsCompletion and normalCompletion? Wo if (higherWeightsFirst) { completions = higherWeightsCompletion.lookup(key, num); } else { completions = normalCompletion.lookup(key, num); } [Stepping through the code, I saw it execute this constructor: /** * This constructor prepares for creating a suggested FST using the * {@link #build(TermFreqIterator)} method. * * @param buckets * The number of weight discretization buckets (see * {@link FSTCompletion} for details). * * @param exactMatchFirst * If <code>true</code> exact matches are promoted to the top of the * suggestions list. Otherwise they appear in the order of * discretized weight and alphabetical within the bucket. */ public FSTCompletionLookup(int buckets, boolean exactMatchFirst) { This constructor never initializes the two *Completion variables ] Third: I got inconsistent results. If I started solr afresh: this error appeared. If I reindexed my test site, then executed my 'problematic searches' , the problem went away. Why would this happen Thanks in advance On Wed, Jun 4, 2014 at 9:32 AM, Will Milspec <will.mils...@gmail.com> wrote: > Hi all, > > Someone posted this problem over a year ago but I did not see a clear > resolution in the thread. > > Intermittently--i.e. for some searches, not others--the > 'suggest/spellcheck' component throws a n NullPointerException (NPE) when a > user executes a search. It fails on FSTCompletionLookup (line 244) > > I'm using solr 4.4. ( I'm using 4.4 to match "what's in production")I > could upgrade if necessary. ) > > Any hints on why it occurs and how to fix? The earlier post alluded to > "changing the field type solved the problem", but did not provide details. > > Thanks > > will > > /select request handler: > ======================== > > <str name="spellcheck">on</str> > <str name="spellcheck.dictionary">suggestDictionary</str> > <str name="spellcheck.extendedResults">false</str> > <str name="spellcheck.count">5</str> > <str name="spellcheck.alternativeTermCount">2</str> > <str name="spellcheck.maxResultsForSuggest">5</str> > <str name="spellcheck.collate">true</str> > <str name="spellcheck.collateExtendedResults">true</str> > <str name="spellcheck.maxCollationTries">5</str> > <str name="spellcheck.maxCollations">3</str> > > spellcheck component: > ======================== > > <searchComponent class="solr.SpellCheckComponent" name="suggest"> > <lst name="spellchecker"> > <str name="name">suggestDictionary</str> > <str > name="classname">org.apache.solr.spelling.suggest.Suggester</str> > <str > name="lookupImpl">org.apache.solr.spelling.suggest.fst.FSTLookupFactory</str> > <str name="field">title</str> > <!-- <str name="field">suggest</str> --> > <float name="threshold">0.</float> > <str name="buildOnCommit">true</str> > </lst> > </searchComponent> > > field type definition: > ======================== > > <fieldType name="text_general" class="solr.TextField" > positionIncrementGap="100"> > <analyzer type="index"> > <tokenizer class="solr.StandardTokenizerFactory"/> > <!-- Use EdgeNGramFilter for wildcard search --> > <filter class="solr.StopFilterFactory" ignoreCase="true" > words="stopwords.txt" /> > <!-- in this example, we will only use synonyms at query time > <filter class="solr.SynonymFilterFactory" > synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/> > --> > <filter class="solr.LowerCaseFilterFactory"/> > </analyzer> > <analyzer type="query"> > <tokenizer class="solr.StandardTokenizerFactory"/> > <filter class="solr.StopFilterFactory" ignoreCase="true" > words="stopwords.txt" /> > <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" > ignoreCase="true" expand="true"/> > <filter class="solr.LowerCaseFilterFactory"/> > </analyzer> > </fieldType> > > field definition: > ======================== > > <field name="title" type="text_general" indexed="true" stored="true" > multiValued="false" omitNorms="false"/> > > It fails here: > =============== > Here's the line that fails. > > @Override > public List<LookupResult> lookup(CharSequence key, boolean > higherWeightsFirst, int num) { > final List<Completion> completions; > if (higherWeightsFirst) { > completions = higherWeightsCompletion.lookup(key, num); > } else { > completions = normalCompletion.lookup(key, num); <-- fails on this > line > > } > >