Scripting: Add score() back to AbstractSearchScript
See #8377 closes #8416 closes #8417
This commit is contained in:
parent
cff544dcc2
commit
ba621ee325
|
@ -24,6 +24,7 @@ import org.apache.lucene.search.Scorer;
|
|||
import org.elasticsearch.index.fielddata.ScriptDocValues;
|
||||
import org.elasticsearch.search.lookup.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -38,6 +39,7 @@ import java.util.Map;
|
|||
public abstract class AbstractSearchScript extends AbstractExecutableScript implements SearchScript {
|
||||
|
||||
private SearchLookup lookup;
|
||||
private Scorer scorer;
|
||||
|
||||
/**
|
||||
* Returns the doc lookup allowing to access field data (cached) values as well as the current document score
|
||||
|
@ -47,6 +49,13 @@ public abstract class AbstractSearchScript extends AbstractExecutableScript impl
|
|||
return lookup.doc();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current score and only applicable when used as a scoring script in a custom score query!.
|
||||
*/
|
||||
protected final float score() throws IOException {
|
||||
return scorer.score();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns field data strings access for the provided field.
|
||||
*/
|
||||
|
@ -95,7 +104,7 @@ public abstract class AbstractSearchScript extends AbstractExecutableScript impl
|
|||
|
||||
@Override
|
||||
public void setScorer(Scorer scorer) {
|
||||
throw new UnsupportedOperationException();
|
||||
this.scorer = scorer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue