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 ninaddesai82 <de...@gmail.com> on 2012/07/06 13:03:50 UTC

Better (and valid) Spellcheck in combination with other parameters with at least one occurance

Hi,
I am trying to implement solr search with spellcheck. - 

My current seach works like this - I have some specific criteria for every
search query. i.e. If I am hitting search with q=restaurants , I also pass
another param say c=mumbai. So solr returns me restaurants in mumbai.

Now I want to implement spellcheck, but at the same time I also want to make
sure that whatever results my spellcheck is providing, are valid (means have
at least one occurance in combination with my other param as in c=city). I
am not able to decide how to achieve that.

i.e. 
If I pass say "hangry" to solr with spell check then spell check retuerns
few suggestions like "hungry", "angry"
However I want to suggest user only those suggestions which have hitcounts
in my data with common field as in c=mumbai.
Otherwise what happens is - solr returns me some suggestion words "hungry ,
angry" and if they dont have ny records with combination of city, it returns
no result, which is bad user experience.

so ideally Solr should return me suggestion for only those words which have
at least 1 count for that suggestion with mumbai. 

I am currently firing 2 queries to luscene in order to achieve this 
Query one - spellcheck - this gives me word suggestns
Query two - with given words in spell check i run facet query to get
occurance counts to check which ones are valid.
But this seems like unnecessary over head (Query two - with facet takes too
long to respond as well). And I am trying to find more optimized way to do
this.

Can anyone suggest me how to do that ?

thanks,
ndesai

--
View this message in context: http://lucene.472066.n3.nabble.com/Better-and-valid-Spellcheck-in-combination-with-other-parameters-with-at-least-one-occurance-tp3993484.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Better (and valid) Spellcheck in combination with other parameters with at least one occurance

Posted by Erick Erickson <er...@gmail.com>.
Be a little patient, we're all volunteers here.....

On Fri, Jul 6, 2012 at 8:55 AM, ninaddesai82 <de...@gmail.com> wrote:
> anyone ??
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Better-and-valid-Spellcheck-in-combination-with-other-parameters-with-at-least-one-occurance-tp3993484p3993498.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Better (and valid) Spellcheck in combination with other parameters with at least one occurance

Posted by ninaddesai82 <de...@gmail.com>.
anyone ??

--
View this message in context: http://lucene.472066.n3.nabble.com/Better-and-valid-Spellcheck-in-combination-with-other-parameters-with-at-least-one-occurance-tp3993484p3993498.html
Sent from the Solr - User mailing list archive at Nabble.com.

RE: Better (and valid) Spellcheck in combination with other parameters with at least one occurance

Posted by "Dyer, James" <Ja...@ingrambook.com>.
Yes, "maxCollationTries" tests the new (collation) queries with all the same parameters as the original query.  Most notably, it uses the same "fq" parameters so it will take in account any filters you were using.

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


-----Original Message-----
From: ninaddesai82 [mailto:desai.ninad@gmail.com] 
Sent: Monday, July 09, 2012 12:45 AM
To: solr-user@lucene.apache.org
Subject: RE: Better (and valid) Spellcheck in combination with other parameters with at least one occurance

Thanks James for your reply.

I am using spell check collation options (except
spellcheck.maxCollationTries). 
However, Will spellcheck.maxCollationTries consider other parqameneters in
query or just all spellcheck words in "q" ?

Becuse in my case, if original query is -->
solr/search/?q=hangry&c=CA&(all suggestion params)

then what i want is luscene suggestion to return is >>
if q=hungry has hits with param c=CA then return suggestion hungry
if q=angry has hits with param c=CA then return suggestion angry

so, does maxCollationTries consider other parameters while collating the
results ?

- Ninad

--
View this message in context: http://lucene.472066.n3.nabble.com/Better-and-valid-Spellcheck-in-combination-with-other-parameters-with-at-least-one-occurance-tp3993484p3993816.html
Sent from the Solr - User mailing list archive at Nabble.com.

RE: Better (and valid) Spellcheck in combination with other parameters with at least one occurance

Posted by ninaddesai82 <de...@gmail.com>.
Thanks James for your reply.

I am using spell check collation options (except
spellcheck.maxCollationTries). 
However, Will spellcheck.maxCollationTries consider other parqameneters in
query or just all spellcheck words in "q" ?

Becuse in my case, if original query is -->
solr/search/?q=hangry&c=CA&(all suggestion params)

then what i want is luscene suggestion to return is >>
if q=hungry has hits with param c=CA then return suggestion hungry
if q=angry has hits with param c=CA then return suggestion angry

so, does maxCollationTries consider other parameters while collating the
results ?

- Ninad

--
View this message in context: http://lucene.472066.n3.nabble.com/Better-and-valid-Spellcheck-in-combination-with-other-parameters-with-at-least-one-occurance-tp3993484p3993816.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Better (and valid) Spellcheck in combination with other parameters with at least one occurance

Posted by Erick Erickson <er...@gmail.com>.
I happen to remember this JIRA: https://issues.apache.org/jira/browse/SOLR-2462

be a bit careful if you use collate with 3.1 or 3.2...

Best
Erick

On Fri, Jul 6, 2012 at 10:36 AM, Dyer, James <Ja...@ingrambook.com> wrote:
> If you're using Solr3.1 or higher, you can do this.  See http://wiki.apache.org/solr/SpellCheckComponent#spellcheck.collate .  Here's a summary:
>
> - specify "spellcheck.collate=true" to get a re-written query made from the individual word suggestions.
>
> - specify "spellcheck.maxCollationTries" to something >0 (10, perhaps) to have it "try" the collation possibilities against the index before returning them to the user.  This means that all collations returned will be guaranteed to return hits.
>
> - specify "spellcheck.collateExtendedResults=true" if you want hit counts for the collation queries and also details on which original word was replaced by which new word.
>
> - specify "spellcheck.maxCollations" to something >1 if you want to get more than 1 collation returned.
>
> If on 4.0-alpha:
>
> - maybe specify "spellcheck.collateParam.mm=100%", if your original query had a very low "mm" value.  This will make the collations returned more meaningful to the user.
>
> - maybe specify "spellcheck.alternativeTermCount" to something >0 if you want the spellchecker to consider that the user might have misspelled words even though the misspelling occurs somewhere in the index.
>
> James Dyer
> E-Commerce Systems
> Ingram Content Group
> (615) 213-4311
>
>
> -----Original Message-----
> From: ninaddesai82 [mailto:desai.ninad@gmail.com]
> Sent: Friday, July 06, 2012 6:04 AM
> To: solr-user@lucene.apache.org
> Subject: Better (and valid) Spellcheck in combination with other parameters with at least one occurance
>
> Hi,
> I am trying to implement solr search with spellcheck. -
>
> My current seach works like this - I have some specific criteria for every
> search query. i.e. If I am hitting search with q=restaurants , I also pass
> another param say c=mumbai. So solr returns me restaurants in mumbai.
>
> Now I want to implement spellcheck, but at the same time I also want to make
> sure that whatever results my spellcheck is providing, are valid (means have
> at least one occurance in combination with my other param as in c=city). I
> am not able to decide how to achieve that.
>
> i.e.
> If I pass say "hangry" to solr with spell check then spell check retuerns
> few suggestions like "hungry", "angry"
> However I want to suggest user only those suggestions which have hitcounts
> in my data with common field as in c=mumbai.
> Otherwise what happens is - solr returns me some suggestion words "hungry ,
> angry" and if they dont have ny records with combination of city, it returns
> no result, which is bad user experience.
>
> so ideally Solr should return me suggestion for only those words which have
> at least 1 count for that suggestion with mumbai.
>
> I am currently firing 2 queries to luscene in order to achieve this
> Query one - spellcheck - this gives me word suggestns
> Query two - with given words in spell check i run facet query to get
> occurance counts to check which ones are valid.
> But this seems like unnecessary over head (Query two - with facet takes too
> long to respond as well). And I am trying to find more optimized way to do
> this.
>
> Can anyone suggest me how to do that ?
>
> thanks,
> ndesai
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Better-and-valid-Spellcheck-in-combination-with-other-parameters-with-at-least-one-occurance-tp3993484.html
> Sent from the Solr - User mailing list archive at Nabble.com.

RE: Better (and valid) Spellcheck in combination with other parameters with at least one occurance

Posted by "Dyer, James" <Ja...@ingrambook.com>.
If you're using Solr3.1 or higher, you can do this.  See http://wiki.apache.org/solr/SpellCheckComponent#spellcheck.collate .  Here's a summary:

- specify "spellcheck.collate=true" to get a re-written query made from the individual word suggestions.

- specify "spellcheck.maxCollationTries" to something >0 (10, perhaps) to have it "try" the collation possibilities against the index before returning them to the user.  This means that all collations returned will be guaranteed to return hits.  

- specify "spellcheck.collateExtendedResults=true" if you want hit counts for the collation queries and also details on which original word was replaced by which new word.

- specify "spellcheck.maxCollations" to something >1 if you want to get more than 1 collation returned.  

If on 4.0-alpha:

- maybe specify "spellcheck.collateParam.mm=100%", if your original query had a very low "mm" value.  This will make the collations returned more meaningful to the user.

- maybe specify "spellcheck.alternativeTermCount" to something >0 if you want the spellchecker to consider that the user might have misspelled words even though the misspelling occurs somewhere in the index.

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


-----Original Message-----
From: ninaddesai82 [mailto:desai.ninad@gmail.com] 
Sent: Friday, July 06, 2012 6:04 AM
To: solr-user@lucene.apache.org
Subject: Better (and valid) Spellcheck in combination with other parameters with at least one occurance

Hi,
I am trying to implement solr search with spellcheck. - 

My current seach works like this - I have some specific criteria for every
search query. i.e. If I am hitting search with q=restaurants , I also pass
another param say c=mumbai. So solr returns me restaurants in mumbai.

Now I want to implement spellcheck, but at the same time I also want to make
sure that whatever results my spellcheck is providing, are valid (means have
at least one occurance in combination with my other param as in c=city). I
am not able to decide how to achieve that.

i.e. 
If I pass say "hangry" to solr with spell check then spell check retuerns
few suggestions like "hungry", "angry"
However I want to suggest user only those suggestions which have hitcounts
in my data with common field as in c=mumbai.
Otherwise what happens is - solr returns me some suggestion words "hungry ,
angry" and if they dont have ny records with combination of city, it returns
no result, which is bad user experience.

so ideally Solr should return me suggestion for only those words which have
at least 1 count for that suggestion with mumbai. 

I am currently firing 2 queries to luscene in order to achieve this 
Query one - spellcheck - this gives me word suggestns
Query two - with given words in spell check i run facet query to get
occurance counts to check which ones are valid.
But this seems like unnecessary over head (Query two - with facet takes too
long to respond as well). And I am trying to find more optimized way to do
this.

Can anyone suggest me how to do that ?

thanks,
ndesai

--
View this message in context: http://lucene.472066.n3.nabble.com/Better-and-valid-Spellcheck-in-combination-with-other-parameters-with-at-least-one-occurance-tp3993484.html
Sent from the Solr - User mailing list archive at Nabble.com.