From e91a0d85a72aaf4e379c3ac997a6297cafaad291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Laleve=CC=81e?= Date: Fri, 6 Jul 2012 22:13:03 +0200 Subject: [PATCH] Better ExplainableSearchScript interface --- .../elasticsearch/index/query/CustomScoreQueryParser.java | 6 +++--- .../org/elasticsearch/script/ExplainableSearchScript.java | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/query/CustomScoreQueryParser.java b/src/main/java/org/elasticsearch/index/query/CustomScoreQueryParser.java index c6195dbb764..f792efd6f4a 100644 --- a/src/main/java/org/elasticsearch/index/query/CustomScoreQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/CustomScoreQueryParser.java @@ -146,12 +146,12 @@ public class CustomScoreQueryParser implements QueryParser { if (script instanceof ExplainableSearchScript) { script.setNextDocId(docId); script.setNextScore(subQueryExpl.getValue()); - exp = ((ExplainableSearchScript) script).explain(); + exp = ((ExplainableSearchScript) script).explain(subQueryExpl); } else { float score = score(docId, subQueryExpl.getValue()); - exp = new Explanation(score, "script score function: product of:"); + exp = new Explanation(score, "script score function: composed of:"); + exp.addDetail(subQueryExpl); } - exp.addDetail(subQueryExpl); return exp; } diff --git a/src/main/java/org/elasticsearch/script/ExplainableSearchScript.java b/src/main/java/org/elasticsearch/script/ExplainableSearchScript.java index 60cf0b46f5a..8bb91724def 100644 --- a/src/main/java/org/elasticsearch/script/ExplainableSearchScript.java +++ b/src/main/java/org/elasticsearch/script/ExplainableSearchScript.java @@ -27,7 +27,9 @@ public interface ExplainableSearchScript extends SearchScript { /** * Build the explanation of the current document being scored + * + * @param subQueryExpl the explanation of the subQuery */ - Explanation explain(); + Explanation explain(Explanation subQueryExpl); }