Package org.elasticsearch.script
Class AggregationScript
java.lang.Object
org.elasticsearch.script.AggregationScript
- All Implemented Interfaces:
ScorerAware
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A factory to construct statefulAggregationScript
factories for a specific index.static interface
A factory to constructAggregationScript
instances. -
Field Summary
Modifier and TypeFieldDescriptionstatic String[]
protected org.apache.lucene.search.Scorable
A scorer that will return the score for the current document when the script is run. -
Constructor Summary
ModifierConstructorDescriptionprotected
AggregationScript(Map<String,Object> params, SearchLookup lookup, org.apache.lucene.index.LeafReaderContext leafContext)
-
Method Summary
Modifier and TypeMethodDescriptionabstract Object
execute()
Map<String,ScriptDocValues<?>>
getDoc()
The doc lookup for the Lucene segment this script was created for.Return the parameters for this script.double
long
Return the result as a long.void
setDocument(int docid)
Set the current document to run the script on next.void
setNextAggregationValue(Object value)
Sets per-document aggregation_value
.void
setScorer(org.apache.lucene.search.Scorable scorer)
-
Field Details
-
PARAMETERS
-
CONTEXT
-
scorer
protected org.apache.lucene.search.Scorable scorerA scorer that will return the score for the current document when the script is run.
-
-
Constructor Details
-
AggregationScript
public AggregationScript(Map<String,Object> params, SearchLookup lookup, org.apache.lucene.index.LeafReaderContext leafContext) -
AggregationScript
protected AggregationScript()
-
-
Method Details
-
getParams
Return the parameters for this script. -
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(org.apache.lucene.search.Scorable scorer)- Specified by:
setScorer
in interfaceScorerAware
-
setNextAggregationValue
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
-
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
-