Class AggregationScript

java.lang.Object
org.elasticsearch.script.AggregationScript
All Implemented Interfaces:
ScorerAware

public abstract class AggregationScript
extends java.lang.Object
implements ScorerAware
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static interface  AggregationScript.Factory
    A factory to construct stateful AggregationScript factories for a specific index.
    static interface  AggregationScript.LeafFactory
    A factory to construct AggregationScript instances.
  • Field Summary

    Fields
    Modifier and Type Field Description
    static ScriptContext<AggregationScript.Factory> CONTEXT  
    static java.lang.String[] PARAMETERS  
    protected org.apache.lucene.search.Scorable scorer
    A scorer that will return the score for the current document when the script is run.
  • Constructor Summary

    Constructors
    Modifier Constructor Description
    protected AggregationScript()  
      AggregationScript​(java.util.Map<java.lang.String,​java.lang.Object> params, SearchLookup lookup, org.apache.lucene.index.LeafReaderContext leafContext)  
  • Method Summary

    Modifier and Type Method Description
    abstract java.lang.Object execute()  
    java.lang.Number get_score()  
    java.lang.Object get_value()  
    java.util.Map<java.lang.String,​ScriptDocValues<?>> getDoc()
    The doc lookup for the Lucene segment this script was created for.
    java.util.Map<java.lang.String,​java.lang.Object> getParams()
    Return the parameters for this script.
    double runAsDouble()  
    long runAsLong()
    Return the result as a long.
    void setDocument​(int docid)
    Set the current document to run the script on next.
    void setNextAggregationValue​(java.lang.Object value)
    Sets per-document aggregation _value.
    void setScorer​(org.apache.lucene.search.Scorable scorer)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PARAMETERS

      public static final java.lang.String[] PARAMETERS
    • CONTEXT

      public static final ScriptContext<AggregationScript.Factory> CONTEXT
    • scorer

      protected org.apache.lucene.search.Scorable scorer
      A scorer that will return the score for the current document when the script is run.
  • Constructor Details

    • AggregationScript

      public AggregationScript​(java.util.Map<java.lang.String,​java.lang.Object> params, SearchLookup lookup, org.apache.lucene.index.LeafReaderContext leafContext)
    • AggregationScript

      protected AggregationScript()
  • Method Details

    • getParams

      public java.util.Map<java.lang.String,​java.lang.Object> getParams()
      Return the parameters for this script.
    • getDoc

      public java.util.Map<java.lang.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​(org.apache.lucene.search.Scorable scorer)
      Specified by:
      setScorer in interface ScorerAware
    • setNextAggregationValue

      public void setNextAggregationValue​(java.lang.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 java.lang.Number get_score()
    • get_value

      public java.lang.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 java.lang.Object execute()