org.elasticsearch.script
Class AbstractSearchScript

java.lang.Object
  extended by org.elasticsearch.script.AbstractExecutableScript
      extended by org.elasticsearch.script.AbstractSearchScript
All Implemented Interfaces:
ExecutableScript, SearchScript
Direct Known Subclasses:
AbstractDoubleSearchScript, AbstractFloatSearchScript, AbstractLongSearchScript

public abstract class AbstractSearchScript
extends AbstractExecutableScript
implements SearchScript

A base class for any script type that is used during the search process (custom score, facets, and so on).

If the script returns a specific numeric type, consider overriding the type specific base classes such as AbstractDoubleSearchScript, AbstractFloatSearchScript and AbstractLongSearchScript for better performance.

The use is required to implement the ExecutableScript.run() method.


Constructor Summary
AbstractSearchScript()
           
 
Method Summary
protected  DocLookup doc()
          Returns the doc lookup allowing to access field data (cached) values as well as the current document score (where applicable).
protected  FieldsLookup fields()
          Allows to access the *stored* fields.
 double runAsDouble()
           
 float runAsFloat()
           
 long runAsLong()
           
protected  float score()
          Returns the current score and only applicable when used as a scoring script in a custom score query!.
 void setNextDocId(int doc)
           
 void setNextReader(org.apache.lucene.index.IndexReader reader)
           
 void setNextScore(float score)
           
 void setScorer(org.apache.lucene.search.Scorer scorer)
           
protected  SourceLookup source()
          Allows to access the actual source (loaded and parsed).
 
Methods inherited from class org.elasticsearch.script.AbstractExecutableScript
setNextVar, unwrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.elasticsearch.script.ExecutableScript
run, setNextVar, unwrap
 

Constructor Detail

AbstractSearchScript

public AbstractSearchScript()
Method Detail

score

protected final float score()
Returns the current score and only applicable when used as a scoring script in a custom score query!. For other cases, use doc() and get the score from it.


doc

protected final DocLookup doc()
Returns the doc lookup allowing to access field data (cached) values as well as the current document score (where applicable).


source

protected final SourceLookup source()
Allows to access the actual source (loaded and parsed).


fields

protected final FieldsLookup fields()
Allows to access the *stored* fields.


setScorer

public void setScorer(org.apache.lucene.search.Scorer scorer)
Specified by:
setScorer in interface SearchScript

setNextReader

public void setNextReader(org.apache.lucene.index.IndexReader reader)
Specified by:
setNextReader in interface SearchScript

setNextDocId

public void setNextDocId(int doc)
Specified by:
setNextDocId in interface SearchScript

setNextScore

public void setNextScore(float score)
Specified by:
setNextScore in interface SearchScript

runAsFloat

public float runAsFloat()
Specified by:
runAsFloat in interface SearchScript

runAsLong

public long runAsLong()
Specified by:
runAsLong in interface SearchScript

runAsDouble

public double runAsDouble()
Specified by:
runAsDouble in interface SearchScript