Amol Bhutada wrote:
If I have a reader and searcher on a indexdata folder and another indexwriter writing documents to the same indexdata folder, do I need to close existing reader and searcher and create new so that newly indexed data comes into search effect?

[ moved from user to dev list]

This is a frequent request. While opening an all-new IndexReader is effective, it is not always efficient. It might be nice to support a more efficient means of re-opening an index.

Perhaps we should add a few new IndexReader methods, as follows:

/** If <code>reader</code>'s index has not been changed, return
  * <code>reader</code>, otherwise return a new [EMAIL PROTECTED] IndexReader}
  * reading the new latest of the index
  */
public static IndexReader open(IndexReader reader) {
  if (isCurrent()) {
    // unchanged: return existing
    return reader;
  }

  // try to incrementally create new reader
  IndexReader result = reader.reopen(reader);
  if (result != null) {
    return result;
  }

  // punt, opening an entirely new reader
  return IndexReader.open(reader.directory());
}

/** Return a new IndexReader reading the current state
  * of the index, re-using reader's resources, or null if this
  * is not possible.
  */
protected IndexReader reopen(IndexReader reader) {
  return null;
}

Then we can add implementations of reopen to SegmentReader and MultiReader that attempt to re-use the existing, already opened segments. This should mostly be simple, but there are a few tricky issues, like detecting whether an already-open segment has had deletions, and deciding when to close obsolete segments.

Does this sound like it would make a good addition? Does someone want to volunteer to implement it?

Doug

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to