lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1524467 - in /lucene/dev/branches/lucene_solr_4_5: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/search/similarities/ lucene/core/src/test/org/apache/lucene/search/similarities/
Date Wed, 18 Sep 2013 15:53:53 GMT
Author: rmuir
Date: Wed Sep 18 15:53:52 2013
New Revision: 1524467

URL: http://svn.apache.org/r1524467
Log:
LUCENE-5221: SimilarityBase.computeNorm is inconsistent with TFIDFSimilarity

Modified:
    lucene/dev/branches/lucene_solr_4_5/   (props changed)
    lucene/dev/branches/lucene_solr_4_5/lucene/   (props changed)
    lucene/dev/branches/lucene_solr_4_5/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/lucene_solr_4_5/lucene/core/   (props changed)
    lucene/dev/branches/lucene_solr_4_5/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
    lucene/dev/branches/lucene_solr_4_5/lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java

Modified: lucene/dev/branches/lucene_solr_4_5/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_5/lucene/CHANGES.txt?rev=1524467&r1=1524466&r2=1524467&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_5/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_5/lucene/CHANGES.txt Wed Sep 18 15:53:52 2013
@@ -118,6 +118,10 @@ Bug Fixes
 * LUCENE-5201: Fixed compression bug in LZ4.compressHC when the input is highly
   compressible and the start offset of the array to compress is > 0.
   (Adrien Grand)
+
+* LUCENE-5221: SimilarityBase did not write norms the same way as DefaultSimilarity
+  if discountOverlaps == false and index-time boosts are present for the field.
+  (Yubin Kim via Robert Muir)
   
 API Changes
 

Modified: lucene/dev/branches/lucene_solr_4_5/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_5/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java?rev=1524467&r1=1524466&r2=1524467&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_5/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
(original)
+++ lucene/dev/branches/lucene_solr_4_5/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
Wed Sep 18 15:53:52 2013
@@ -233,7 +233,7 @@ public abstract class SimilarityBase ext
     if (discountOverlaps)
       numTerms = state.getLength() - state.getNumOverlap();
     else
-      numTerms = state.getLength() / state.getBoost();
+      numTerms = state.getLength();
     return encodeNormValue(state.getBoost(), numTerms);
   }
   

Modified: lucene/dev/branches/lucene_solr_4_5/lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_5/lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java?rev=1524467&r1=1524466&r2=1524467&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_5/lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java
(original)
+++ lucene/dev/branches/lucene_solr_4_5/lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java
Wed Sep 18 15:53:52 2013
@@ -26,6 +26,7 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.TextField;
+import org.apache.lucene.index.FieldInvertState;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
@@ -576,4 +577,20 @@ public class TestSimilarityBase extends 
     dir.close();
     super.tearDown();
   }
+  
+  // LUCENE-5221
+  public void testDiscountOverlapsBoost() throws IOException {
+    DefaultSimilarity expected = new DefaultSimilarity();
+    SimilarityBase actual = new DFRSimilarity(new BasicModelIne(), new AfterEffectB(), new
NormalizationH2());
+    expected.setDiscountOverlaps(false);
+    actual.setDiscountOverlaps(false);
+    FieldInvertState state = new FieldInvertState("foo");
+    state.setLength(5);
+    state.setNumOverlap(2);
+    state.setBoost(3);
+    assertEquals(expected.computeNorm(state), actual.computeNorm(state));
+    expected.setDiscountOverlaps(true);
+    actual.setDiscountOverlaps(true);
+    assertEquals(expected.computeNorm(state), actual.computeNorm(state));
+  }
 }



Mime
View raw message