lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r745796 - in /lucene/java/branches/lucene_2_4: ./ CHANGES.txt src/java/org/apache/lucene/index/DocInverterPerField.java src/test/org/apache/lucene/index/TestIndexWriter.java
Date Thu, 19 Feb 2009 09:50:56 GMT
Author: mikemccand
Date: Thu Feb 19 09:50:55 2009
New Revision: 745796

URL: http://svn.apache.org/viewvc?rev=745796&view=rev
Log:
LUCENE-1442 (on 2.4 branch): fix double-counting of offsets of multi-valued NOT_ANALYZED fields

Modified:
    lucene/java/branches/lucene_2_4/   (props changed)
    lucene/java/branches/lucene_2_4/CHANGES.txt
    lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/index/DocInverterPerField.java
    lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestIndexWriter.java

Propchange: lucene/java/branches/lucene_2_4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 19 09:50:55 2009
@@ -1 +1 @@
-/lucene/java/trunk:708549,709456
+/lucene/java/trunk:708549,709456,712233

Modified: lucene/java/branches/lucene_2_4/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4/CHANGES.txt?rev=745796&r1=745795&r2=745796&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4/CHANGES.txt (original)
+++ lucene/java/branches/lucene_2_4/CHANGES.txt Thu Feb 19 09:50:55 2009
@@ -23,6 +23,9 @@
    (masking an actual IOException) that takes String or File path.
    (Mike McCandless)
 
+5. LUCENE-1442: Multiple-valued NOT_ANALYZED fields can double-count
+   token offsets.  (Mike McCandless)
+
 ======================= Release 2.4.0 2008-10-06 =======================
 
 Changes in backwards compatibility policy

Modified: lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/index/DocInverterPerField.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/index/DocInverterPerField.java?rev=745796&r1=745795&r2=745796&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/index/DocInverterPerField.java
(original)
+++ lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/index/DocInverterPerField.java
Thu Feb 19 09:50:55 2009
@@ -79,7 +79,7 @@
         if (!field.isTokenized()) {		  // un-tokenized field
           String stringValue = field.stringValue();
           final int valueLength = stringValue.length();
-          Token token = perThread.localToken.reinit(stringValue, fieldState.offset, fieldState.offset
+ valueLength);
+          Token token = perThread.localToken.reinit(stringValue, 0, valueLength);
           boolean success = false;
           try {
             consumer.add(token);

Modified: lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=745796&r1=745795&r2=745796&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestIndexWriter.java
(original)
+++ lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestIndexWriter.java
Thu Feb 19 09:50:55 2009
@@ -4168,4 +4168,26 @@
     // throws IllegalStateEx w/o bug fix
     writer.close();
   }
+
+  // LUCENE-1442
+  public void testDoubleOffsetCounting() throws Exception {
+    MockRAMDirectory dir = new MockRAMDirectory();
+    IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+    Document doc = new Document();
+    Field f = new Field("field", "abcd", Field.Store.NO, Field.Index.NOT_ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+    doc.add(f);
+    doc.add(f);
+    w.addDocument(doc);
+    w.close();
+
+    IndexReader r = IndexReader.open(dir);
+    TermVectorOffsetInfo[] termOffsets = ((TermPositionVector) r.getTermFreqVector(0, "field")).getOffsets(0);
+    assertEquals(2, termOffsets.length);
+    assertEquals(0, termOffsets[0].getStartOffset());
+    assertEquals(4, termOffsets[0].getEndOffset());
+    assertEquals(4, termOffsets[1].getStartOffset());
+    assertEquals(8, termOffsets[1].getEndOffset());
+    r.close();
+    dir.close();
+  }
 }



Mime
View raw message