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