i'm using lucene to index documents and perform a search after which, i immediately delete them.
all this can be considered as a somewhat atomic action that includes the following steps:
index (writer) --> search (searcher) --> get docs by score
(reader) --> delete docs (reader)
this action can be performed by multiple concurrent threads on the same index (using FSDirectory
).
IMPORTANT NOTE: each thread handles a separate set of documents so one thread will not touch another thread's documents
for that purpose i have a few questions:
1) should i use a single instances (for all threads) of IndexWriter
, IndexReader
and IndexSearcher
? (they're supposed to be thread safe)
2) can an IndexWriter
manipulate an index while and IndexReader
deletes documents? do i need to close one for the other to do its thing?
meaning, can one thread write to an index while another one deletes from it (as i mentioned earlier, i can guarantee that they handle separate sets of data)
3) any other good practices and suggestions you might have will be most appreciated.
thanks a lot!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…