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 Frank Kunemann <fr...@innosystec.de> on 2006/09/26 11:07:20 UTC

How to tell if IndexSearcher/IndexReader was closed?

Hi all,

after I delete some entries from the index, I close the IndexSearcher to
ensure that the changes are done.
But after this I couldn't figure out a way to tell if the searcher is closed
or not.
Any ideas?


Regards
Frank


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


Re: How to tell if IndexSearcher/IndexReader was closed?

Posted by Simon Willnauer <si...@googlemail.com>.
I guess there are many possibilities to implement some control
structure to track the references to your searcher / reader. As it is
best practice to have one single searcher open you can track the
reference to the searcher while one reference is hold by the class you
request your searcher from. If you close your searcher you decrement
the reference which is hold by the, I will call it "controller", class
and create a new searcher. If no reference to the searcher is
remaining you close the searcher and it will get garbage collected.

If you use this kind of pattern you might have more than one searcher
open for a short time. but if the last "search client" has decremented
the reference the searcher will be closed. You don't have to care
whether the searcher is closed or not, you won't get a reference to a
closed searcher instance.

Solr and GData Server uses this kind of reference tracking for this purpose.

have a look at http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/utils/ReferenceCounter.java?view=markup


best regards Simon
On 9/26/06, Frank Kunemann <fr...@innosystec.de> wrote:
> Hi all,
>
> after I delete some entries from the index, I close the IndexSearcher to
> ensure that the changes are done.
> But after this I couldn't figure out a way to tell if the searcher is closed
> or not.
> Any ideas?
>
>
> Regards
> Frank
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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