You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Kudzanai <ku...@gmail.com> on 2011/09/22 13:03:19 UTC
SpellCheck Print Multiple Collations
Hi,
This is probably a very basic question but how do I get the returned
collations.
My spell check request is
http://localhost:8983/solr/autocomplete/select?spellcheck.q=ipood%20tough&spellcheck=true&spellcheck.collate=true&spellcheck.build=true&spellcheck.maxCollations=3&rows=3&spellcheck.count=5
Part of my response is:
<str name="collation">ipod tough</str>
<str name="collation">ipad tough</str>
<str name="collation">wood tough</str></lst>
My results are accurate but now how do i get the collations. What method do
i use in the API?
--
View this message in context: http://lucene.472066.n3.nabble.com/SpellCheck-Print-Multiple-Collations-tp3358391p3358391.html
Sent from the Solr - User mailing list archive at Nabble.com.
RE: SpellCheck Print Multiple Collations
Posted by Kudzanai <ku...@gmail.com>.
spellcheck.collateExtendedResults = true seems to have sorted my problem.
My other parameters are:
spellcheck = true
spellcheck.count = aNumResults
spellcheck.q = SEARCH TEXT
spellcheck.build= true
spellcheck.collate= true
spellcheck.maxCollations= 4
spellcheck.collateExtendedResults = true
suggestionCount = 5;
rows = 0
It seems to work perfectly now. Thanks a lot.
--
View this message in context: http://lucene.472066.n3.nabble.com/SpellCheck-Print-Multiple-Collations-tp3358391p3358970.html
Sent from the Solr - User mailing list archive at Nabble.com.
RE: SpellCheck Print Multiple Collations
Posted by "Dyer, James" <Ja...@ingrambook.com>.
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.vudzijena@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.
RE: SpellCheck Print Multiple Collations
Posted by Kudzanai <ku...@gmail.com>.
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.
RE: SpellCheck Print Multiple Collations
Posted by "Dyer, James" <Ja...@ingrambook.com>.
If using SolrJ,
use QueryResponse.getSpellCheckResponse().getCollatedResults() . This returns a List<Collation> . On each Collation object, getCollationQueryString() will return the corrected queries.
Note that unless you specify "spellcheck.maxCollationTries", the collations might not return anything if re-queried.
James Dyer
E-Commerce Systems
Ingram Content Group
(615) 213-4311
-----Original Message-----
From: Kudzanai [mailto:kudzanai.vudzijena@gmail.com]
Sent: Thursday, September 22, 2011 6:03 AM
To: solr-user@lucene.apache.org
Subject: SpellCheck Print Multiple Collations
Hi,
This is probably a very basic question but how do I get the returned
collations.
My spell check request is
http://localhost:8983/solr/autocomplete/select?spellcheck.q=ipood%20tough&spellcheck=true&spellcheck.collate=true&spellcheck.build=true&spellcheck.maxCollations=3&rows=3&spellcheck.count=5
Part of my response is:
<str name="collation">ipod tough</str>
<str name="collation">ipad tough</str>
<str name="collation">wood tough</str></lst>
My results are accurate but now how do i get the collations. What method do
i use in the API?
--
View this message in context: http://lucene.472066.n3.nabble.com/SpellCheck-Print-Multiple-Collations-tp3358391p3358391.html
Sent from the Solr - User mailing list archive at Nabble.com.