Try adding "spellcheck.collateExtendedResults=true" to your query (without 
"maxCollationTries") to see if solrj correctly returns all 4 collations in that 
case.  In any case, if solrj is returning the last collation 4 times, this is 
likely a bug.

The likely reason why "spellcheck.maxCollationTries=1" results in a null is 
that the first collation it tried didn't result in any hits.  Because you're 
only allowing 1 try it won't attempt to check any alternatives and instead 
returns nothing.  Generally if using this parameter, you'd want to set it at 
least to whatever value you've got for "maxCollations", possibly a few higher.

James Dyer
E-Commerce Systems
Ingram Content Group
(615) 213-4311


-----Original Message-----
From: Kudzanai [mailto:kudzanai.vudzij...@gmail.com] 
Sent: Thursday, September 22, 2011 9:20 AM
To: solr-user@lucene.apache.org
Subject: RE: SpellCheck Print Multiple Collations

I am using solrJ.

Here is what my method looks like.

 List<String> suggestedTermsList = new ArrayList<String>();
    if(aQueryResponse == null) {
      return suggestedTermsList;
    }

    try {
      SpellCheckResponse spellCheckResponse =
aQueryResponse.getSpellCheckResponse();
      if(spellCheckResponse == null) {
        throw new Exception("No SpellCheckResponse in QueryResponse");
      }  
      
     List<Collation> collationList =
spellCheckResponse.getCollatedResults();
      
      for(Collation c : collationList){
        suggestedTermsList.add(c.getCollationQueryString());
      }
      
    }catch(Exception e) {
      Trace.Log("SolrSpellCheck",Trace.HIGH, "Exception: " +
e.getMessage());
    }
    return suggestedTermsList;
  }

My response header is like so:

spellcheck={suggestions={ipood={numFound=5,startOffset=0,endOffset=5,suggestion=[ipod,
ipad, wood, food, pod]},collation=ipod tough,collation=ipad
tough,collation=wood tough,collation=food tough}}}


I get 4 collations  [collation=ipod tough,collation=ipad
tough,collation=wood tough,collation=food tough] ,
which I want to add to a List suggestedTermsList which I then return to the
calling code. Right now my ArrayList has 4 collations but it only has the
last collation repeated 4 times. i.e food tough - four times.

spellcheck.maxCollationTries set to 1 causes my QueryResponse to be null.


--
View this message in context: 
http://lucene.472066.n3.nabble.com/SpellCheck-Print-Multiple-Collations-tp3358391p3358930.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to