Mailing List Archive

IndexSearcher and IndexWriter.rollback
I’m using an IndexSearcher created from an IndexWriter (NRT mode).

Up until now the IW was kept open forever.

I want to properly handle cases where an indexing task failed and call IW.rollback to discard the incomplete changes.

The problem I’m facing is that rollback also closes the writer.

Q1: Can I somehow keep using the same IndexSearcher instance after the writer is closed?

Q2: Can I rollback the changes without closing the writer?



Creating a new IndexSearcher is possible but can be a bit fragile as it is used by many threads concurrently.
Re: IndexSearcher and IndexWriter.rollback [ In reply to ]
Q1. Are you using a SearcherManager or a direct IndexSearcher? If you are
using a SearcherManager, you could just call `maybeRefresh()` and then
re-acquire a new `IndexSearcher`. The method docs
<https://lucene.apache.org/core/9_0_0/core/org/apache/lucene/search/ReferenceManager.html#maybeRefresh()>
also mention that it is fine to call `maybeRefresh` on multiple threads
concurrently. Only the first
thread will attempt the refresh; subsequent threads will see that another
thread is already handling refresh and will return immediately.

Q2. I don't think the IW exposes an interface to rollback to a commit
without closing the writer.

Hope this helps.
Gautam Worah.


On Thu, Apr 14, 2022 at 6:35 AM <erel@eth.gl> wrote:

> I’m using an IndexSearcher created from an IndexWriter (NRT mode).
>
> Up until now the IW was kept open forever.
>
> I want to properly handle cases where an indexing task failed and call
> IW.rollback to discard the incomplete changes.
>
> The problem I’m facing is that rollback also closes the writer.
>
> Q1: Can I somehow keep using the same IndexSearcher instance after the
> writer is closed?
>
> Q2: Can I rollback the changes without closing the writer?
>
>
>
> Creating a new IndexSearcher is possible but can be a bit fragile as it is
> used by many threads concurrently.
>
>
>
>
>
>