Package org.elasticsearch.script
Class AggregationScript
- java.lang.Object
-
- org.elasticsearch.script.AggregationScript
-
- All Implemented Interfaces:
ScorerAware
public abstract class AggregationScript extends Object implements ScorerAware
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAggregationScript.FactoryA factory to construct statefulAggregationScriptfactories for a specific index.static interfaceAggregationScript.LeafFactoryA factory to constructAggregationScriptinstances.
-
Field Summary
Fields Modifier and Type Field Description static ScriptContext<AggregationScript.Factory>CONTEXTstatic String[]PARAMETERSprotected ScorablescorerA scorer that will return the score for the current document when the script is run.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAggregationScript()AggregationScript(Map<String,Object> params, SearchLookup lookup, LeafReaderContext leafContext)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Objectexecute()Numberget_score()Objectget_value()Map<String,ScriptDocValues<?>>getDoc()The doc lookup for the Lucene segment this script was created for.Map<String,Object>getParams()Return the parameters for this script.doublerunAsDouble()longrunAsLong()Return the result as a long.voidsetDocument(int docid)Set the current document to run the script on next.voidsetNextAggregationValue(Object value)Sets per-document aggregation_value.voidsetScorer(Scorable scorer)
-
-
-
Field Detail
-
PARAMETERS
public static final String[] PARAMETERS
-
CONTEXT
public static final ScriptContext<AggregationScript.Factory> CONTEXT
-
scorer
protected Scorable scorer
A scorer that will return the score for the current document when the script is run.
-
-
Constructor Detail
-
AggregationScript
public AggregationScript(Map<String,Object> params, SearchLookup lookup, LeafReaderContext leafContext)
-
AggregationScript
protected AggregationScript()
-
-
Method Detail
-
getDoc
public Map<String,ScriptDocValues<?>> getDoc()
The doc lookup for the Lucene segment this script was created for.
-
setDocument
public void setDocument(int docid)
Set the current document to run the script on next.
-
setScorer
public void setScorer(Scorable scorer)
- Specified by:
setScorerin interfaceScorerAware
-
setNextAggregationValue
public void setNextAggregationValue(Object value)
Sets per-document aggregation_value.The default implementation just calls
setNextVar("_value", value)but some engines might want to handle this differently for better performance.- Parameters:
value- per-document value, typically a String, Long, or Double
-
get_score
public Number get_score()
-
get_value
public Object get_value()
-
runAsLong
public long runAsLong()
Return the result as a long. This is used by aggregation scripts over long fields.
-
runAsDouble
public double runAsDouble()
-
execute
public abstract Object execute()
-
-