lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Query Filters on term A in query "A AND (B OR C OR D)"
Date Thu, 13 Nov 2003 21:15:32 GMT
On Thursday, November 13, 2003, at 04:07  PM, Jie Yang wrote:
> Erik, Just to make sure I understand you right, In an
> example query:  ZipCode:CA10927 AND Gender:Male

Are we talking about that query being entered by the user and you 
handing it just like that to QueryParser?  If so, then QueryFilter 
won't help.

> Sure I know ZipCode returns fewer results, do you mean
> I build a filter
>
> QueryFilter x = new QueryFilter("ZipCode", "CA10927",
> ..);

Well, that is not quite the right API, but something like this:

     Query maleQuery = new TermQuery(new Term("Gender", "Male"));
     Filter filter = new QueryFilter(maleQuery);
     Hits hits = searcher.search(new TermQuery("ZipCode","CA10927"), 
filter);

Keep in mind all that Doug has said on this topic as well.  In this 
case, it probably won't be any faster than a single query, maybe even 
slower.  But if you use the same instance of the filter for future 
searches there will certainly be a benefit.

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message