You shouldn't have to write first to intermediate RAMDirectorys anymore.... just share a single IndexWriter instance across all of your threads.
Mike McCandless http://blog.mikemccandless.com On Wed, Jan 11, 2012 at 12:19 PM, Cheng <zhoucheng2...@gmail.com> wrote: > 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? > > Thanks --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org