Skip to content

Apache Lucene open-source search software

LUCENE-3224: checkindex fails if docfreq >= skipInterval and term is indexed more than once at same position

Robert Muiradf6eee90e19
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 7acde2d4522..eee6854970c 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -514,6 +514,10 @@ Bug fixes
causing the file to sometimes be larger than it needed to be. (Mike
McCandless)
+* LUCENE-3224: Fixed a big where CheckIndex would incorrectly report a
+ corrupt index if a term with docfreq >= 16 was indexed more than once
+ at the same position. (Robert Muir)
+
New Features
* LUCENE-3290: Added FieldInvertState.numUniqueTerms
diff --git a/lucene/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/src/java/org/apache/lucene/index/CheckIndex.java
index 3bfe5dca914..e54309d3ebd 100644
--- a/lucene/src/java/org/apache/lucene/index/CheckIndex.java
+++ b/lucene/src/java/org/apache/lucene/index/CheckIndex.java
@@ -835,8 +835,8 @@ public class CheckIndex {
if (pos < 0) {
throw new RuntimeException("position " + pos + " is out of bounds");
}
- if (pos <= lastPosition) {
- throw new RuntimeException("position " + pos + " is <= lastPosition " + lastPosition);
+ if (pos < lastPosition) {
+ throw new RuntimeException("position " + pos + " is < lastPosition " + lastPosition);
}
lastPosition = pos;
}
diff --git a/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java b/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java
index b46c37d965d..a3c89d3c244 100644
--- a/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java
+++ b/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java
@@ -47,6 +47,22 @@ public class TestSameTokenSamePosition extends LuceneTestCase {
riw.close();
dir.close();
}
+
+ /**
+ * Same as the above, but with more docs
+ */
+ public void testMoreDocs() throws Exception {
+ Directory dir = newDirectory();
+ RandomIndexWriter riw = new RandomIndexWriter(random, dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new BugReproAnalyzer()));
+ Document doc = new Document();
+ doc.add(new Field("eng", "Six drunken" /*This shouldn't matter. */,
+ Field.Store.YES, Field.Index.ANALYZED));
+ for (int i = 0; i < 100; i++) {
+ riw.addDocument(doc);
+ }
+ riw.close();
+ dir.close();
+ }
}
final class BugReproAnalyzer extends Analyzer{