while calling addindexes or addindexes with no optimize can any gurantee be given about the document order in the new documents given that the order of directories/indexreader is fixed.
So is it that ith document coming from jth indexreader will always have some x(i,j) position in the final merged index ?
Do you mean sequentially, using IW.addIndexes(new IndexReader[]{index1,index2}), so that the fields from documents in one index become attached to the fields in the other index under the same doc IDs? No, it absolutely doesn’t work this way.
Or do you mean to merge the two indexes in parallel? Then just open them with ParallelReader
and submit this parallel reader to IW.addIndexes(). ParallelReader doesn’t expose sub-readers to SegmentMerger, it returns null from getSequentialSubReaders() so that SegmentMerger has to use the documents as they are returned from ParallelReader.document(int). Net effect is that fields from sub-readers become merged on the same doc id, and will be thus recorded in the output index.