Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-6524

Create an IndexWriter from an already opened NRT or non-NRT reader


    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 5.3, 6.0
    • None
    • None
    • New


      I'd like to add a new ctor to IndexWriter, letting you start from an already
      opened NRT or non-NRT DirectoryReader. I think this is a long missing
      API in Lucene today, and we've talked in the past about different ways
      to fix it e.g. factoring out a shared reader pool between writer and reader.

      One use-case, which I hit in LUCENE-5376: if you have a read-only
      index, so you've opened a non-NRT DirectoryReader to search it, and
      then you want to "upgrade" to a read/write index, we don't handle that
      very gracefully now because you are forced to open 2X the

      But with this API, IW populates its reader pool with the incoming
      SegmentReaders so they are shared on any subsequent NRT reopens /
      segment merging / deletes applying, etc.

      Another (more expert) use case is allowing rollback to an NRT-point.
      Today, you can only rollback to a commit point (segments_N). But an
      NRT reader also reflects a valid "point in time" view of the index (it
      just doesn't have a segments_N file, and its ref'd files are not
      fsync'd), so with this change you can close your old writer, open a
      new one from this NRT point, and revert all changes that had been done
      after the NRT reader was opened from the old writer.


        1. LUCENE-6524.patch
          41 kB
          Michael McCandless
        2. LUCENE-6524.patch
          27 kB
          Michael McCandless
        3. LUCENE-6524.patch
          25 kB
          Michael McCandless



            mikemccand Michael McCandless
            mikemccand Michael McCandless
            0 Vote for this issue
            4 Start watching this issue