On Wed, Jun 15, 2016 at 6:08 AM, Mark Shapiro <mshap...@palamida.com> wrote: > private static IndexSearcher getSearcher( String[] indexDirs ) throws > Exception { > IndexReader[] readers = new IndexReader[indexDirs.length]; > FSDirectory[] directorys = new FSDirectory[indexDirs.length]; > > for ( int i = 0; i < indexDirs.length; ++i ) { > File file = new File( indexDirs[i] ); > directorys[i] = ( bWindows ) ? new MMapDirectory( file ) : new > NIOFSDirectory( file ); > directorys[i].setReadChunkSize( Integer.MAX_VALUE ); > readers[i] = IndexReader.open( directorys[i], true ); > } > > MultiReader multiReader = new MultiReader( readers, true ); > IndexSearcher searcher = new IndexSearcher( multiReader, executorService ); > // ExecutorService > return searcher; > }
OK, so if you want to retrieve the Document, you can call document(int) on this multiReader and it will automatically take care of retrieving it from the right underlying reader. If you want to do it manually, you can keep around the IndexReader[] and binary search on it to figure out which one contains the doc ID. Or you can build an int[] of the starting doc IDs for each reader and use ReaderUtil.subIndex to compute it probably more efficiently. This is what composite readers use to do the same thing internally. TX --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org