You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Eric Jain <Er...@isb-sib.ch> on 2004/06/10 15:17:35 UTC

CachedQuery

I noticed that searching for terms that appear in a significant number
of documents tends to be relatively slow. For example

   foo AND (bar:yes OR xyz)

where every document has a field 'bar' with a value of either 'yes' or
'no'. Had a look at CachingWrapperFilter, unfortunately this class
doesn't seem to be any help here. Perhaps I need to create a CachedQuery
class that caches Weight objects for wrapped Query objects (and subclass
QueryParser to make use of this)? But would this work? Any ideas?


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


Re: CachedQuery

Posted by Eric Jain <Er...@isb-sib.ch>.
> How about the new FilteredQuery (added in the latest Lucene 1.4 release 
> - or earlier?).  I'm not sure it would suffice for that particular query 
> though.  It would, however, work well for:
> 
>     foo OR (bar:yes AND xyz)
> 
> as you could use a QueryFilter on bar:yes nested in a FilteredQuery with 
> a TermQuery for xyz, and then wrapped in a BooleanQuery as two 
> non-required clauses.  As for QueryParser... FilteredQuery is not 
> currently supported, although you could perhaps inject it by subclassing 
> (?).

Unfortunately it is also possible (and frequent) for the entire query to 
be nothing but

   bar:yes

in which case the FilteredQuery approach wouldn't work, as far as I can 
see. On the other hand, I just realize that caching query objects won't 
do any good either, as most work is done when the score method of the 
query object is called (wild speculation).

Perhaps what I need is some kind of rule-based query optimizer...

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


Re: CachedQuery

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jun 10, 2004, at 9:17 AM, Eric Jain wrote:
> I noticed that searching for terms that appear in a significant number
> of documents tends to be relatively slow. For example
>
>   foo AND (bar:yes OR xyz)
>
> where every document has a field 'bar' with a value of either 'yes' or
> 'no'. Had a look at CachingWrapperFilter, unfortunately this class
> doesn't seem to be any help here. Perhaps I need to create a 
> CachedQuery
> class that caches Weight objects for wrapped Query objects (and 
> subclass
> QueryParser to make use of this)? But would this work? Any ideas?

How about the new FilteredQuery (added in the latest Lucene 1.4 release 
- or earlier?).  I'm not sure it would suffice for that particular 
query though.  It would, however, work well for:

	foo OR (bar:yes AND xyz)

as you could use a QueryFilter on bar:yes nested in a FilteredQuery 
with a TermQuery for xyz, and then wrapped in a BooleanQuery as two 
non-required clauses.  As for QueryParser... FilteredQuery is not 
currently supported, although you could perhaps inject it by 
subclassing (?).

Maybe FilteredQuery would work for you?  But I'm not seeing how with 
the query you provided.

	Erik


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