|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.search.NRTManager
public class NRTManager
Utility class to manage sharing near-real-time searchers across multiple searching threads.
NOTE: to use this class, you must call maybeReopen(boolean)
periodically. The NRTManagerReopenThread
is a
simple class to do this on a periodic basis. If you
implement your own reopener, be sure to call addWaitingListener(org.apache.lucene.search.NRTManager.WaitingListener)
so your reopener is notified when a
caller is waiting for a specific generation searcher.
Nested Class Summary | |
---|---|
static interface |
NRTManager.WaitingListener
NRTManager invokes this interface to notify it when a caller is waiting for a specific generation searcher to be visible. |
Constructor Summary | |
---|---|
NRTManager(IndexWriter writer,
ExecutorService es,
SearcherWarmer warmer)
Create new NRTManager. |
|
NRTManager(IndexWriter writer,
ExecutorService es,
SearcherWarmer warmer,
boolean alwaysApplyDeletes)
Expert: just like NRTManager(IndexWriter,ExecutorService,SearcherWarmer) ,
but you can also specify whether every searcher must
apply deletes. |
|
NRTManager(IndexWriter writer,
SearcherWarmer warmer)
Create new NRTManager. |
Method Summary | |
---|---|
long |
addDocument(Document d)
|
long |
addDocument(Document d,
Analyzer a)
|
long |
addDocuments(Collection<Document> docs)
|
long |
addDocuments(Collection<Document> docs,
Analyzer a)
|
long |
addIndexes(Directory... dirs)
|
long |
addIndexes(IndexReader... readers)
|
void |
addWaitingListener(NRTManager.WaitingListener l)
Adds a listener, to be notified when a caller is waiting for a specific generation searcher to be visible. |
void |
close()
Close this NRTManager to future searching. |
long |
deleteAll()
|
long |
deleteDocuments(Query... queries)
|
long |
deleteDocuments(Query q)
|
long |
deleteDocuments(Term... terms)
|
long |
deleteDocuments(Term t)
|
long |
getCurrentSearchingGen(boolean applyAllDeletes)
Returns generation of current searcher. |
SearcherManager |
getSearcherManager(boolean applyAllDeletes)
Returns a SearcherManager . |
boolean |
maybeReopen(boolean applyAllDeletes)
|
void |
removeWaitingListener(NRTManager.WaitingListener l)
Remove a listener added with addWaitingListener(org.apache.lucene.search.NRTManager.WaitingListener) . |
long |
updateDocument(Term t,
Document d)
|
long |
updateDocument(Term t,
Document d,
Analyzer a)
|
long |
updateDocuments(Term t,
Collection<Document> docs)
|
long |
updateDocuments(Term t,
Collection<Document> docs,
Analyzer a)
|
SearcherManager |
waitForGeneration(long targetGen,
boolean requireDeletes)
Waits for a given SearcherManager target generation to be available
via getSearcherManager(boolean) . |
SearcherManager |
waitForGeneration(long targetGen,
boolean requireDeletes,
long time,
TimeUnit unit)
Waits for a given SearcherManager target generation to be available
via getSearcherManager(boolean) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NRTManager(IndexWriter writer, SearcherWarmer warmer) throws IOException
writer
- IndexWriter to open near-real-time
readerswarmer
- optional 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 SearcherWarmer
is
not invoked for the initial searcher; you should
warm it yourself if necessary.
IOException
public NRTManager(IndexWriter writer, ExecutorService es, SearcherWarmer warmer) throws IOException
writer
- IndexWriter to open near-real-time
readerses
- optional ExecutorService so different segments can
be searched concurrently (see IndexSearcher.IndexSearcher(IndexReader, ExecutorService)
.
Pass null
to search segments sequentially.warmer
- optional 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 SearcherWarmer
is
not invoked for the initial searcher; you should
warm it yourself if necessary.
IOException
public NRTManager(IndexWriter writer, ExecutorService es, SearcherWarmer warmer, boolean alwaysApplyDeletes) throws IOException
NRTManager(IndexWriter,ExecutorService,SearcherWarmer)
,
but you can also specify whether every searcher must
apply deletes. This is useful for cases where certain
uses can tolerate seeing some deleted docs, since
reopen time is faster if deletes need not be applied.
IOException
Method Detail |
---|
public void addWaitingListener(NRTManager.WaitingListener l)
public void removeWaitingListener(NRTManager.WaitingListener l)
addWaitingListener(org.apache.lucene.search.NRTManager.WaitingListener)
.
public long updateDocument(Term t, Document d, Analyzer a) throws IOException
IOException
public long updateDocument(Term t, Document d) throws IOException
IOException
public long updateDocuments(Term t, Collection<Document> docs, Analyzer a) throws IOException
IOException
public long updateDocuments(Term t, Collection<Document> docs) throws IOException
IOException
public long deleteDocuments(Term t) throws IOException
IOException
public long deleteDocuments(Term... terms) throws IOException
IOException
public long deleteDocuments(Query q) throws IOException
IOException
public long deleteDocuments(Query... queries) throws IOException
IOException
public long deleteAll() throws IOException
IOException
public long addDocument(Document d, Analyzer a) throws IOException
IOException
public long addDocuments(Collection<Document> docs, Analyzer a) throws IOException
IOException
public long addDocument(Document d) throws IOException
IOException
public long addDocuments(Collection<Document> docs) throws IOException
IOException
public long addIndexes(Directory... dirs) throws CorruptIndexException, IOException
CorruptIndexException
IOException
public long addIndexes(IndexReader... readers) throws CorruptIndexException, IOException
CorruptIndexException
IOException
public SearcherManager waitForGeneration(long targetGen, boolean requireDeletes)
SearcherManager
target generation to be available
via getSearcherManager(boolean)
. If the current generation is less
than the given target generation this method will block until the
correspondent SearcherManager
is reopened by another thread via
maybeReopen(boolean)
or until the NRTManager
is closed.
targetGen
- the generation to wait forrequireDeletes
- true
iff the generation requires deletes to be applied otherwise false
SearcherManager
with the given target generationpublic SearcherManager waitForGeneration(long targetGen, boolean requireDeletes, long time, TimeUnit unit)
SearcherManager
target generation to be available
via getSearcherManager(boolean)
. If the current generation is less
than the given target generation this method will block until the
correspondent SearcherManager
is reopened by another thread via
maybeReopen(boolean)
, the given waiting time has elapsed, or until
the NRTManager
is closed.
NOTE: if the waiting time elapses before the requested target generation is
available the latest SearcherManager
is returned instead.
targetGen
- the generation to wait forrequireDeletes
- true
iff the generation requires deletes to be
applied otherwise false
time
- the time to wait for the target generationunit
- the waiting time's time unit
SearcherManager
with the given target generation or the
latest SearcherManager
if the waiting time elapsed before
the requested generation is available.public long getCurrentSearchingGen(boolean applyAllDeletes)
public boolean maybeReopen(boolean applyAllDeletes) throws IOException
IOException
public void close() throws IOException
SearcherManager.release(IndexSearcher)
after they are done.
NOTE: caller must separately close the writer.
close
in interface Closeable
IOException
public SearcherManager getSearcherManager(boolean applyAllDeletes)
SearcherManager
. If applyAllDeletes
is
true
the returned manager is guaranteed to have all deletes
applied on the last reopen. Otherwise the latest manager with or without deletes
is returned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |