Class SearchScript

    • Constructor Detail

      • SearchScript

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

      • getParams

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

        protected final LeafSearchLookup getLeafLookup()
        The leaf lookup for the Lucene segment this script was created for.
      • getDoc

        public final LeafDocLookup 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​( scorer)
        Specified by:
        setScorer in interface ScorerAware
      • getScore

        public double getScore()
        Return the score of the current document.
      • 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.

        value - per-document value, typically a String, Long, or Double
      • setNextVar

        public void setNextVar​(java.lang.String field,
                               java.lang.Object value)
      • runAsLong

        public long runAsLong()
        Return the result as a long. This is used by aggregation scripts over long fields.
      • run

        public java.lang.Object run()
      • runAsDouble

        public abstract double runAsDouble()
        Return the result as a double. This is the main use case of search script, used for document scoring.