Skip to content

Apache Lucene open-source search software

LUCENE-4249: fix PayloadTermQuery to defer to the PayloadFunction in explain

Robert Muir2ba546ef2efb
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index b3baa80d422..95ff5ddd2f1 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -11,6 +11,10 @@ http://s.apache.org/luceneversions
New features
+* LUCENE-4249: Changed the explanation of the PayloadTermWeight to use the
+ underlying PayloadFunction's explanation as the explanation
+ for the payload score. (Scott Smerchek via Robert Muir)
+
* LUCENE-4201: Added JapaneseIterationMarkCharFilter to normalize Japanese
iteration marks. (Robert Muir, Christian Moen)
diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java b/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java
index 4d07328c7d2..30d5bacfbcf 100644
--- a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java
@@ -190,7 +190,7 @@ public class PayloadTermQuery extends SpanTermQuery {
// whether to load the payload or not
// GSI: I suppose we could toString the payload, but I don't think that
// would be a good idea
- Explanation payloadExpl = new Explanation(scorer.getPayloadScore(), "scorePayload(...)");
+ Explanation payloadExpl = function.explain(doc, scorer.payloadsSeen, scorer.payloadScore);
payloadExpl.setValue(scorer.getPayloadScore());
// combined
ComplexExplanation result = new ComplexExplanation();