You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by do...@apache.org on 2008/06/12 06:15:12 UTC

svn commit: r666949 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java src/test/org/apache/lucene/search/payloads/TestBoostingTermQuery.java

Author: doronc
Date: Wed Jun 11 21:15:10 2008
New Revision: 666949

URL: http://svn.apache.org/viewvc?rev=666949&view=rev
Log:
LUCENE-1303: BoostingTermQuery's explanation marked as a Match 
             depending only upon the non-payload part of the score.

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/payloads/TestBoostingTermQuery.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=666949&r1=666948&r2=666949&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Wed Jun 11 21:15:10 2008
@@ -119,6 +119,11 @@
 
 12. LUCENE-1299: Fixed NPE in SpellChecker when IndexReader is not null and field is (Grant Ingersoll)
 
+13. LUCENE-1303: Fixed BoostingTermQuery's explanation to be marked as a Match 
+    depending only upon the non-payload score part, regardless of the effect of 
+    the payload on the score. Prior to this, score of a query containing a BTQ 
+    differed from its explanation. (Doron Cohen)
+
 New features
 
  1. LUCENE-1137: Added Token.set/getFlags() accessors for passing more information about a Token through the analysis

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java?rev=666949&r1=666948&r2=666949&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java Wed Jun 11 21:15:10 2008
@@ -121,7 +121,7 @@
 
 
       public Explanation explain(final int doc) throws IOException {
-        Explanation result = new Explanation();
+        ComplexExplanation result = new ComplexExplanation();
         Explanation nonPayloadExpl = super.explain(doc);
         result.addDetail(nonPayloadExpl);
         //QUESTION: Is there a wau to avoid this skipTo call?  We need to know whether to load the payload or not
@@ -140,6 +140,7 @@
         payloadBoost.setDescription("scorePayload(...)");
         result.setValue(nonPayloadExpl.getValue() * avgPayloadScore);
         result.setDescription("btq, product of:");
+        result.setMatch(nonPayloadExpl.getValue()==0 ? Boolean.FALSE : Boolean.TRUE); // LUCENE-1303
         return result;
       }
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/payloads/TestBoostingTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/payloads/TestBoostingTermQuery.java?rev=666949&r1=666948&r2=666949&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/payloads/TestBoostingTermQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/payloads/TestBoostingTermQuery.java Wed Jun 11 21:15:10 2008
@@ -92,7 +92,7 @@
     for (int i = 0; i < 1000; i++) {
       Document doc = new Document();
       Field noPayloadField = new Field("noPayLoad", English.intToEnglish(i), Field.Store.YES, Field.Index.TOKENIZED);
-      noPayloadField.setBoost(0);
+      //noPayloadField.setBoost(0);
       doc.add(noPayloadField);
       doc.add(new Field("field", English.intToEnglish(i), Field.Store.YES, Field.Index.TOKENIZED));
       doc.add(new Field("multiField", English.intToEnglish(i) + "  " + English.intToEnglish(i), Field.Store.YES, Field.Index.TOKENIZED));
@@ -186,7 +186,7 @@
     query.add(c2);
     TopDocs hits = searcher.search(query, null, 100);
     assertTrue("hits is null and it shouldn't be", hits != null);
-    //assertTrue("hits Size: " + hits.totalHits + " is not: " + 1, hits.totalHits == 1);
+    assertTrue("hits Size: " + hits.totalHits + " is not: " + 1, hits.totalHits == 1);
     int[] results = new int[1];
     results[0] = 0;//hits.scoreDocs[0].doc;
     CheckHits.checkHitCollector(query, "noPayLoad", searcher, results);