diff --git a/src/java/org/apache/lucene/index/IndexWriter.java b/src/java/org/apache/lucene/index/IndexWriter.java index fa1335c12cf..41e2a6d3bd1 100644 --- a/src/java/org/apache/lucene/index/IndexWriter.java +++ b/src/java/org/apache/lucene/index/IndexWriter.java @@ -206,7 +206,8 @@ public final class IndexWriter { flushRamSegments(); while (segmentInfos.size() > 1 || (segmentInfos.size() == 1 && - SegmentReader.hasDeletions(segmentInfos.info(0)))){ + (SegmentReader.hasDeletions(segmentInfos.info(0)) || + segmentInfos.info(0).dir != directory))) { int minSegment = segmentInfos.size() - mergeFactor; mergeSegments(minSegment < 0 ? 0 : minSegment); }