lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Noll <>
Subject Re: IndexSearcher cache
Date Sun, 04 Mar 2007 22:35:00 GMT
MC Moisei wrote:
> Hi to all members of the user group!
> Let me get to my problem. I use Lucene in two different parts of the
> application. One is the SearchService and one is an AOP interceptor that
> intercepts any changes in the Searcheable entities. This last part is
> removing the document from the index and add the document again.
> That being said, here's my test case.
> My searcheable item has in content "apple banana" if I search for apple
> or banana I get it back amoung the results.
> If I modify it and remove banana from content when I search for apple or
> banana I get same results as above (!?)
> If I restart my application so the IndexSearcher is recreated, I run the
> test above I only get my document if I search for apple - that leads me
> to conclude that the IndexSearcher caches the results.

It doesn't "cache" the results, but what happens is the underlying 
IndexReader effectively sees no changes for its lifetime (this is 
presumably for safety; since usually you don't want the index changing 
underneath while trying to do queries.)

> Is there a way to clear IndexSeacher when I do the reindexing ( I use
> IndexModifer for the AOP interceptor) ?

Yep.  Close the IndexSearcher and the IndexReader, and reopen them.

If you need to do queries quite often then it probably makes sense to do 
this only every now and then.


Daniel Noll

Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia    Ph: +61 2 9280 0699
Web:                               Fax: +61 2 9212 6902

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message