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: QueryFilter vs CachingWrapperFilter vs RangeQuery
Date Tue, 07 Dec 2004 20:18:29 GMT
On Dec 7, 2004, at 3:06 PM, Ben Rooney wrote:
> i'm trying to understand the difference/effects between QueryFilter vs
> CachingWrapperFilter and when you would use one vs the other and how
> they work exactly.

QueryFilter caches the results (bit set of documents) of a query by 
IndexReader.

CachingWrapperFilter does not actually do any filtering of its own, but 
merely wraps the results of another non-caching filter, such as 
DateFilter.  CachingWrapperFilter was added to disconnect caching from 
filtering.  QueryFilter is the exception as it came first and already 
does caching.  If you're using QueryFilter, there is no need to concern 
yourself with CachingWrapperFilter.

> also, when exactly will the cache be cleared.  looking at the source
> code, it appears when the IndexReader is released it would be cleared.
> does this mean i should keep a reference to the SearchIndexer until i
> want the results to be cleared?  for example, in a class file the
> executes the search, i would keep a static reference to SearchIndexer
> and then when i want to invalidate the cache, set it to null or create 
> a
> new instance of it?

How you keep a reference to the IndexSearcher instance is up to the 
design of your system.  But, yes, you do need to keep a reference to it 
for the cache to work properly.  If you use a new IndexSearcher 
instance (I'm simplifying here, you could have an IndexReader instance 
yourself too, but I'm ignoring that possibility) then the filtering 
process occurs for each search rather than using the cache.

	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