Apache Lucene open-source search software
LUCENE-1303: BoostingTermQuery's explanation marked as a Match depending only upon the non-payload part of the score.
Doron Cohend69885c9d71c
diff --git a/CHANGES.txt b/CHANGES.txtindex b7315ab9c0c..3f6bda780de 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -119,6 +119,11 @@ Bug fixes12. 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 features1. LUCENE-1137: Added Token.set/getFlags() accessors for passing more information about a Token through the analysisdiff --git a/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java b/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.javaindex 179eb3fe091..7f5af8fe10e 100644--- a/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java+++ b/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java@@ -121,7 +121,7 @@ public class BoostingTermQuery extends SpanTermQuery{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 @@ public class BoostingTermQuery extends SpanTermQuery{payloadBoost.setDescription("scorePayload(...)");result.setValue(nonPayloadExpl.getValue() * avgPayloadScore);result.setDescription("btq, product of:");+ result.setMatch(nonPayloadExpl.getValue()==0 ? Boolean.FALSE : Boolean.TRUE); // LUCENE-1303return result;}}diff --git a/src/test/org/apache/lucene/search/payloads/TestBoostingTermQuery.java b/src/test/org/apache/lucene/search/payloads/TestBoostingTermQuery.javaindex 93b5c637a04..631448f6ca8 100644--- a/src/test/org/apache/lucene/search/payloads/TestBoostingTermQuery.java+++ b/src/test/org/apache/lucene/search/payloads/TestBoostingTermQuery.java@@ -92,7 +92,7 @@ public class TestBoostingTermQuery extends LuceneTestCase {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 @@ public class TestBoostingTermQuery extends LuceneTestCase {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);