You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/08/11 16:31:56 UTC
svn commit: r1371961 - in /lucene/dev/trunk: ./ lucene/ lucene/CHANGES.txt
lucene/core/ lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
Author: rmuir
Date: Sat Aug 11 14:31:56 2012
New Revision: 1371961
URL: http://svn.apache.org/viewvc?rev=1371961&view=rev
Log:
Don't allow negatives in the positions file
Modified:
lucene/dev/trunk/ (props changed)
lucene/dev/trunk/lucene/ (props changed)
lucene/dev/trunk/lucene/CHANGES.txt (contents, props changed)
lucene/dev/trunk/lucene/core/ (props changed)
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1371961&r1=1371960&r2=1371961&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Sat Aug 11 14:31:56 2012
@@ -31,6 +31,11 @@ Bug Fixes
had a custom Similarity where coord(1,1) != 1F, then the rewritten
query would be scored differently. (Robert Muir)
+* Don't allow negatives in the positions file. If you have an index
+ from 2.4.0 or earlier with such negative positions, and you already
+ upgraded to 3.x, then to Lucene 4.0-ALPHA or -BETA, you should run
+ CheckIndex. If it fails, then you need to upgrade again to 4.0 (Robert Muir)
+
======================= Lucene 4.0.0-BETA =======================
New features
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java?rev=1371961&r1=1371960&r2=1371961&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java Sat Aug 11 14:31:56 2012
@@ -822,11 +822,8 @@ public class CheckIndex {
if (hasPositions) {
for(int j=0;j<freq;j++) {
final int pos = postings.nextPosition();
- // NOTE: pos=-1 is allowed because of ancient bug
- // (LUCENE-1542) whereby IndexWriter could
- // write pos=-1 when first token's posInc is 0
- if (pos < -1) {
+ if (pos < 0) {
throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " is out of bounds");
}
if (pos < lastPos) {
@@ -919,14 +916,8 @@ public class CheckIndex {
int lastOffset = 0;
for(int posUpto=0;posUpto<freq;posUpto++) {
final int pos = postings.nextPosition();
- // NOTE: pos=-1 is allowed because of ancient bug
- // (LUCENE-1542) whereby IndexWriter could
- // write pos=-1 when first token's posInc is 0
- // (separately: analyzers should not give
- // posInc=0 to first token); also, term
- // vectors are allowed to return pos=-1 if
- // they indexed offset but not positions:
- if (pos < -1) {
+
+ if (pos < 0) {
throw new RuntimeException("position " + pos + " is out of bounds");
}
if (pos < lastPosition) {
@@ -1498,7 +1489,7 @@ public class CheckIndex {
int pos = postings.nextPosition();
if (postingsPostings != null) {
int postingsPos = postingsPostings.nextPosition();
- if (pos != -1 && postingsPos != -1 && pos != postingsPos) {
+ if (terms.hasPositions() && pos != postingsPos) {
throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + ": pos=" + pos + " differs from postings pos=" + postingsPos);
}
}