diff --git a/lucene/src/java/org/apache/lucene/search/NRTManager.java b/lucene/src/java/org/apache/lucene/search/NRTManager.java index e00b87caf9f..744b8b73ea1 100644 --- a/lucene/src/java/org/apache/lucene/search/NRTManager.java +++ b/lucene/src/java/org/apache/lucene/search/NRTManager.java @@ -28,11 +28,13 @@ import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.CorruptIndexException; +import org.apache.lucene.index.IndexReader; // javadocs import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.Term; -import org.apache.lucene.search.NRTManagerReopenThread; +import org.apache.lucene.search.IndexSearcher; // javadocs +import org.apache.lucene.store.Directory; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.ThreadInterruptedException; @@ -60,6 +62,25 @@ public class NRTManager implements Closeable { private final ReentrantLock reopenLock = new ReentrantLock(); private final Condition newGeneration = reopenLock.newCondition(); + /** + * Create new NRTManager. + * + * @param writer IndexWriter to open near-real-time + * readers + * @param warmer optional {@link SearcherWarmer}. Pass + * null if you don't require the searcher to warmed + * before going live. If this is non-null then a + * merged segment warmer is installed on the + * provided IndexWriter's config. + * + *

NOTE: the provided {@link SearcherWarmer} is + * not invoked for the initial searcher; you should + * warm it yourself if necessary. + */ + public NRTManager(IndexWriter writer, SearcherWarmer warmer) throws IOException { + this(writer, null, warmer, true); + } + /** * Create new NRTManager. * @@ -152,12 +173,30 @@ public class NRTManager implements Closeable { return indexingGen.get(); } + public long deleteDocuments(Term... terms) throws IOException { + writer.deleteDocuments(terms); + // Return gen as of when indexing finished: + return indexingGen.get(); + } + public long deleteDocuments(Query q) throws IOException { writer.deleteDocuments(q); // Return gen as of when indexing finished: return indexingGen.get(); } + public long deleteDocuments(Query... queries) throws IOException { + writer.deleteDocuments(queries); + // Return gen as of when indexing finished: + return indexingGen.get(); + } + + public long deleteAll() throws IOException { + writer.deleteAll(); + // Return gen as of when indexing finished: + return indexingGen.get(); + } + public long addDocument(Iterable d, Analyzer a) throws IOException { writer.addDocument(d, a); // Return gen as of when indexing finished: @@ -182,6 +221,18 @@ public class NRTManager implements Closeable { return indexingGen.get(); } + public long addIndexes(Directory... dirs) throws CorruptIndexException, IOException { + writer.addIndexes(dirs); + // Return gen as of when indexing finished: + return indexingGen.get(); + } + + public long addIndexes(IndexReader... readers) throws CorruptIndexException, IOException { + writer.addIndexes(readers); + // Return gen as of when indexing finished: + return indexingGen.get(); + } + /** * Waits for a given {@link SearcherManager} target generation to be available * via {@link #getSearcherManager(boolean)}. If the current generation is less