Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-1255: revert this change (allow pos=-1 again) since it's not backwards compatible

Michael McCandless8f1feaa48437
diff --git a/src/java/org/apache/lucene/index/CheckIndex.java b/src/java/org/apache/lucene/index/CheckIndex.java
index b3f86afbad2..4dea08f9ceb 100644
--- a/src/java/org/apache/lucene/index/CheckIndex.java
+++ b/src/java/org/apache/lucene/index/CheckIndex.java
@@ -104,7 +104,6 @@ public class CheckIndex {
String sFormat = "";
boolean skip = false;
- boolean allowMinusOnePosition = true;
if (format == SegmentInfos.FORMAT)
sFormat = "FORMAT [Lucene Pre-2.1]";
@@ -118,7 +117,6 @@ public class CheckIndex {
// LUCENE-1255: All versions before 2.3.2/2.4 were
// able to create position=-1 when the very first
// Token has positionIncrement 0
- allowMinusOnePosition = false;
if (format == SegmentInfos.FORMAT_CHECKSUM)
sFormat = "FORMAT_CHECKSUM [Lucene 2.4]";
else if (format == SegmentInfos.FORMAT_DEL_COUNT)
@@ -235,7 +233,7 @@ public class CheckIndex {
totPos += freq;
for(int j=0;j<freq;j++) {
final int pos = termPositions.nextPosition();
- if (pos < -1 || (pos == -1 && !allowMinusOnePosition))
+ if (pos < -1)
throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " is out of bounds");
if (pos < lastPos)
throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " < lastPos " + lastPos);
diff --git a/src/java/org/apache/lucene/index/DocumentsWriterFieldData.java b/src/java/org/apache/lucene/index/DocumentsWriterFieldData.java
index a084982446a..bfa0be01a8a 100644
--- a/src/java/org/apache/lucene/index/DocumentsWriterFieldData.java
+++ b/src/java/org/apache/lucene/index/DocumentsWriterFieldData.java
@@ -243,9 +243,6 @@ final class DocumentsWriterFieldData implements Comparable {
Token token = stream.next(localToken);
if (token == null) break;
position += (token.getPositionIncrement() - 1);
- // LUCENE-1255: don't allow negative position
- if (position < 0)
- position = 0;
addPosition(token);
if (++length >= maxFieldLength) {
if (threadState.docWriter.infoStream != null)
diff --git a/src/test/org/apache/lucene/index/TestIndexWriter.java b/src/test/org/apache/lucene/index/TestIndexWriter.java
index db4803350e7..229f63723f1 100644
--- a/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -3596,7 +3596,7 @@ public class TestIndexWriter extends LuceneTestCase
TermPositions tps = s.getIndexReader().termPositions(new Term("field", "a"));
assertTrue(tps.next());
assertEquals(1, tps.freq());
- assertEquals(0, tps.nextPosition());
+ assertEquals(-1, tps.nextPosition());
w.close();
assertTrue(_TestUtil.checkIndex(dir));