fix naming, also make explainable search script extend search script
This commit is contained in:
parent
a77c824476
commit
dcf9194820
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
|
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
|
||||||
import org.elasticsearch.common.lucene.search.function.ScoreFunction;
|
import org.elasticsearch.common.lucene.search.function.ScoreFunction;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.script.ExplanableSearchScript;
|
import org.elasticsearch.script.ExplainableSearchScript;
|
||||||
import org.elasticsearch.script.SearchScript;
|
import org.elasticsearch.script.SearchScript;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -143,10 +143,10 @@ public class CustomScoreQueryParser implements QueryParser {
|
||||||
@Override
|
@Override
|
||||||
public Explanation explainScore(int docId, Explanation subQueryExpl) {
|
public Explanation explainScore(int docId, Explanation subQueryExpl) {
|
||||||
Explanation exp;
|
Explanation exp;
|
||||||
if (script instanceof ExplanableSearchScript) {
|
if (script instanceof ExplainableSearchScript) {
|
||||||
script.setNextDocId(docId);
|
script.setNextDocId(docId);
|
||||||
script.setNextScore(subQueryExpl.getValue());
|
script.setNextScore(subQueryExpl.getValue());
|
||||||
exp = ((ExplanableSearchScript) script).explain();
|
exp = ((ExplainableSearchScript) script).explain();
|
||||||
} else {
|
} else {
|
||||||
float score = score(docId, subQueryExpl.getValue());
|
float score = score(docId, subQueryExpl.getValue());
|
||||||
exp = new Explanation(score, "script score function: product of:");
|
exp = new Explanation(score, "script score function: product of:");
|
||||||
|
|
|
@ -23,12 +23,10 @@ import org.apache.lucene.search.Explanation;
|
||||||
/**
|
/**
|
||||||
* To be implemented by {@link SearchScript} which can provided an {@link Explanation} of the score
|
* To be implemented by {@link SearchScript} which can provided an {@link Explanation} of the score
|
||||||
*/
|
*/
|
||||||
public interface ExplanableSearchScript {
|
public interface ExplainableSearchScript extends SearchScript {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the explanation of the current document being scored
|
* Build the explanation of the current document being scored
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
Explanation explain();
|
Explanation explain();
|
||||||
|
|
|
@ -26,8 +26,8 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A search script.
|
* A search script.
|
||||||
*
|
*
|
||||||
* @see ExplanableSearchScript for script which can explain a score
|
* @see ExplainableSearchScript for script which can explain a score
|
||||||
*/
|
*/
|
||||||
public interface SearchScript extends ExecutableScript {
|
public interface SearchScript extends ExecutableScript {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue