From adf6eee90e190dd60b22ca8fcf6289eabb12b7d5 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Sun, 17 Jul 2011 10:53:51 +0000 Subject: [PATCH] LUCENE-3224: checkindex fails if docfreq >= skipInterval and term is indexed more than once at same position git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1147578 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 4 ++++ .../java/org/apache/lucene/index/CheckIndex.java | 4 ++-- .../lucene/index/TestSameTokenSamePosition.java | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) 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{