On 11/29/06, Eric Brown <[EMAIL PROTECTED]> wrote:
I'm using lucene as a backend for my webservices that provide add, remove and search operations. When I add or remove documents via IndexModifier, I believe I'm supposed to close the IndexSearcher I use for query requests. However, I cache Hits and I believe the javadocs indicate closing an IndexSearcher will invalidate the cached Hits such that trying to retrieve a doc may throw an exception. So my solution is to wrap the IndexSearcher in another class with a finalizer that closes the IndexSearcher when all the Hits dereference it. My question is whether my cached hits have a solid reference to IndexSearcher such that I can rely on it being closed only after I expire the Hits from the cache?
Yes, they do.
Also, should I keep one IndexModifier open for the life of my service/ application or should I open and close it when I get new requests to add or remove documents? (I don't really have control over batching unfortunately -- though I've certainly pointed it out.)
IndexModifier currently has very low performance with mixed adds and deletes. You can keep the same one over the lifetime of the app though. If you haven't seen it, another alternative that might fit your needs is Solr. -Yonik http://incubator.apache.org/solr Solr, the open-source Lucene search server --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]