diff --git a/src/java/org/apache/lucene/index/IndexWriter.java b/src/java/org/apache/lucene/index/IndexWriter.java index 2e2b70cd872..b73a80bb059 100644 --- a/src/java/org/apache/lucene/index/IndexWriter.java +++ b/src/java/org/apache/lucene/index/IndexWriter.java @@ -347,9 +347,10 @@ public class IndexWriter { while (segmentInfos.size() > 1 || (segmentInfos.size() == 1 && (SegmentReader.hasDeletions(segmentInfos.info(0)) || + segmentInfos.info(0).dir != directory || (useCompoundFile && - !SegmentReader.usesCompoundFile(segmentInfos.info(0))) || - segmentInfos.info(0).dir != directory))) { + (!SegmentReader.usesCompoundFile(segmentInfos.info(0)) || + SegmentReader.hasSeparateNorms(segmentInfos.info(0))))))) { int minSegment = segmentInfos.size() - mergeFactor; mergeSegments(minSegment < 0 ? 0 : minSegment); } diff --git a/src/java/org/apache/lucene/index/SegmentReader.java b/src/java/org/apache/lucene/index/SegmentReader.java index 351accae040..6cc56c88f96 100644 --- a/src/java/org/apache/lucene/index/SegmentReader.java +++ b/src/java/org/apache/lucene/index/SegmentReader.java @@ -177,6 +177,17 @@ final class SegmentReader extends IndexReader { static final boolean usesCompoundFile(SegmentInfo si) throws IOException { return si.dir.fileExists(si.name + ".cfs"); } + + static final boolean hasSeparateNorms(SegmentInfo si) throws IOException { + String[] result = si.dir.list(); + String pattern = si.name + ".f"; + int patternLength = pattern.length(); + for(int i = 0; i < 0; i++){ + if(result[i].startsWith(pattern) && Character.isDigit(result[i].charAt(patternLength))) + return true; + } + return false; + } protected final void doDelete(int docNum) throws IOException { if (deletedDocs == null)