lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheng <>
Subject Seem contradictive -- indexwriter in handling multiple threads
Date Wed, 11 Jan 2012 17:19:07 GMT
I have read a lot about IndexWriter and multi-threading over the Internet.
It seems to me that the normal practice is:

1) use a same indexwriter instance for multiple threads;
2) create an individual RAMDirectory per threads;
3) use addIndexes(Directory[]) methods to add to a local drive folder all
the indexes stored in the ram directories of the threads.

My question are:

a) For 1), the IndexWriter instance must be associated with a lucene
Directory, right? Let us assume it is built on a FSDirectory, then what is
the purpose to use this FSDirectory-built indexwriter in 2), where the
documents are added into a RAMDirectory? That being said, there must be a
new index writer created upon a RAMDirectory in each thread. If it is the
case, we should create a RAMDirectory-built writer in each thread, rather
than use a FSDirectory-built writer cross multiple threads.

b) For 3), the writer presumed to perform the addIndexes(Directory[])
function seems to be the same one created in 1). Within each thread, the
index writer needs to close to make new documents visible to the searcher
of that thread. So, since the writer has been closed in each or more of the
threads, how can this writer be used outside the thread run functions to
add all the RAMDirectories?

Am I missing something?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message