diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java index 90d6c6f047f..c6281bb723e 100644 --- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java +++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java @@ -681,6 +681,7 @@ public class CheckIndex { DocsEnum docs = null; DocsEnum docsAndFreqs = null; DocsAndPositionsEnum postings = null; + DocsAndPositionsEnum offsets = null; String lastField = null; final FieldsEnum fieldsEnum = fields.iterator(); @@ -756,6 +757,7 @@ public class CheckIndex { docs = termsEnum.docs(liveDocs, docs, false); docsAndFreqs = termsEnum.docs(liveDocs, docsAndFreqs, true); postings = termsEnum.docsAndPositions(liveDocs, postings, false); + offsets = termsEnum.docsAndPositions(liveDocs, offsets, true); if (hasOrd) { long ord = -1; @@ -779,19 +781,29 @@ public class CheckIndex { final DocsEnum docsAndFreqs2; final boolean hasPositions; final boolean hasFreqs; - if (postings != null) { + final boolean hasOffsets; + if (offsets != null) { + docs2 = postings = offsets; + docsAndFreqs2 = postings = offsets; + hasOffsets = true; + hasPositions = true; + hasFreqs = true; + } else if (postings != null) { docs2 = postings; docsAndFreqs2 = postings; + hasOffsets = false; hasPositions = true; hasFreqs = true; } else if (docsAndFreqs != null) { docs2 = docsAndFreqs; docsAndFreqs2 = docsAndFreqs; + hasOffsets = false; hasPositions = false; hasFreqs = true; } else { docs2 = docs; docsAndFreqs2 = null; + hasOffsets = false; hasPositions = false; hasFreqs = false; } @@ -826,6 +838,7 @@ public class CheckIndex { lastDoc = doc; int lastPos = -1; + int lastOffset = 0; if (hasPositions) { for(int j=0;j