Nalini,

You could take the code from SpellCheckCollator#collate and have it issue a 
test query for each word individually instead of for each collation.  This 
would do exactly what you want. See 
http://svn.apache.org/repos/asf/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java

If you are concerned this isn't low-level enough and that performance would 
suffer, then see https://issues.apache.org/jira/browse/SOLR-3240 , which has a 
patch that uses a collector that quits after finding one document.  This makes 
each test query faster at the expense of not getting exact hit-counts.

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


-----Original Message-----
From: Nalini Kartha [mailto:nalinikar...@gmail.com] 
Sent: Thursday, December 27, 2012 1:09 PM
To: solr-user@lucene.apache.org
Subject: Re: Converting fq params to Filter object

Hi Eric,

Sorry, I think I wasn't very clear in explaining what we need to do.

We don't really need to do any complicated overriding, just want to change
the DirectSpellChecker to issue a query for every correction it finds *with
fq params from the original query taken into account* so that we can check
if the correction would actually result in some hits.

I was thinking of implementing this using the IndexSearcher.search(Query
query, Filter filter, int n) method where 'query' is a regular TermQuery
(the term is the correction) and 'filter' would represent the fq params.
What I'm not sure about is how to convert the fq params from Solr into a
Filter object and whether this is something we need to build ourselves or
if there's an existing API for this.

Also, I'm new to this code so not sure if I'm approaching this the wrong
way. Any advice/pointers are much appreciated.

Thanks,
Nalini



On Thu, Dec 27, 2012 at 12:53 PM, Erik Hatcher <erik.hatc...@gmail.com>wrote:

> I think the answer is yes, that there's a better way to doing all of this.
>  But I'm not yet sure what this all entails in your situation.  What are
> you overriding with the Lucene searches?   I imagine Solr has the
> flexibility to handle what you're trying to do without overriding anything
> core in SolrIndexSearcher.
>
> Generally, the way to get a custom filter in place is to create a custom
> query parser and use that for your fq parameter, like fq={!myparser
> param1='some value'}possible+expression+if+needed, so maybe that helps?
>
> Tell us more about what you're doing specifically, and maybe we can guide
> you to a more elegant way to plug in any custom logic you want.
>
>         Erik
>
> On Dec 26, 2012, at 11:21 , Nalini Kartha wrote:
>
> > Hi,
> >
> > I'm trying to figure out how to convert the fq params that are being
> passed
> > to Solr into something that can be used to filter the results of a query
> > that's being issued against the Lucene IndexSearcher (I'm modifying some
> > Lucene code to issue the query so calling through to one of the
> > SolrIndexSearcher methods would be ugly).
> >
> > Looks like one of the IndexSearcher.search(Query query, Filter filter,
> ...)
> > methods would do what I want but I'm wondering if there's any easy way of
> > converting the fq params into a Filter? Or is there a better way of doing
> > all of this?
> >
> > Thanks,
> > Nalini
>
>

Reply via email to