Class StoredScriptSource

org.elasticsearch.cluster.AbstractDiffable<StoredScriptSource>
org.elasticsearch.script.StoredScriptSource
All Implemented Interfaces:
Diffable<StoredScriptSource>, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject

public class StoredScriptSource extends AbstractDiffable<StoredScriptSource> implements Writeable, org.elasticsearch.common.xcontent.ToXContentObject
StoredScriptSource represents user-defined parameters for a script saved in the ClusterState.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent

    org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params

    Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable

    Writeable.Reader<V>, Writeable.Writer<V>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static org.elasticsearch.common.xcontent.ParseField
    Standard ParseField for lang on the inner level.
    static org.elasticsearch.common.xcontent.ParseField
    Standard ParseField for options on the inner level.
    static org.elasticsearch.common.xcontent.ParseField
    Standard ParseField for outer level of stored script source.
    static org.elasticsearch.common.xcontent.ParseField
    Standard ParseField for source on the inner level.

    Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
     lang,  source, <,​> options)
    Standard StoredScriptSource constructor.
    Reads a StoredScriptSource from a stream.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     o)
     
    fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser, boolean ignoreEmpty)
    This will parse XContent into a StoredScriptSource.
     
    <,​>
     
     
    int
     
    parse​(BytesReference content, org.elasticsearch.common.xcontent.XContentType xContentType)
    This will parse XContent into a StoredScriptSource.
    Required for ScriptMetadata.ScriptMetadataDiff.
     
    org.elasticsearch.common.xcontent.XContentBuilder
    toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
    This will write XContent from a StoredScriptSource.
    void
    Writes a StoredScriptSource to a stream.

    Methods inherited from class org.elasticsearch.cluster.AbstractDiffable

    diff, readDiffFrom

    Methods inherited from class java.lang.

    , , , , , , ,

    Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject

    isFragment
  • Field Details

    • SCRIPT_PARSE_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField SCRIPT_PARSE_FIELD
      Standard ParseField for outer level of stored script source.
    • LANG_PARSE_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField LANG_PARSE_FIELD
      Standard ParseField for lang on the inner level.
    • SOURCE_PARSE_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField SOURCE_PARSE_FIELD
      Standard ParseField for source on the inner level.
    • OPTIONS_PARSE_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField OPTIONS_PARSE_FIELD
      Standard ParseField for options on the inner level.
  • Constructor Details

    • StoredScriptSource

      public StoredScriptSource( lang,  source, <,​> options)
      Standard StoredScriptSource constructor.
      Parameters:
      lang - The language to compile the script with. Must not be null.
      source - The source source to compile with. Must not be null.
      options - Compiler options to be compiled with. Must not be null, use an empty to represent no options.
    • StoredScriptSource

      public StoredScriptSource(StreamInput in) throws
      Reads a StoredScriptSource from a stream. Version 5.3+ will read all of the lang, source, and options parameters. For versions prior to 5.3, only the source parameter will be read in as a bytes reference.
      Throws:
  • Method Details

    • parse

      public static StoredScriptSource parse(BytesReference content, org.elasticsearch.common.xcontent.XContentType xContentType)
      This will parse XContent into a StoredScriptSource. The following formats can be parsed: The simple script format with no compiler options or user-defined params: Example: {"script": "return Math.log(doc.popularity) * 100;"} The above format requires the lang to be specified using the deprecated stored script namespace (as a url parameter during a put request). See ScriptMetadata for more information about the stored script namespaces. The complex script format using the new stored script namespace where lang and source are required but options is optional: { "script" : { "lang" : "<lang>", "source" : "<source>", "options" : { "option0" : "<option0>", "option1" : "<option1>", ... } } } Example: { "script": { "lang" : "painless", "source" : "return Math.log(doc.popularity) * params.multiplier" } } The use of "source" may also be substituted with "code" for backcompat with 5.3 to 5.5 format. For example: { "script" : { "lang" : "<lang>", "code" : "<source>", "options" : { "option0" : "<option0>", "option1" : "<option1>", ... } } } Note that the "source" parameter can also handle template parsing including from a complex JSON object.
      Parameters:
      content - The content from the request to be parsed as described above.
      Returns:
      The parsed StoredScriptSource.
    • fromXContent

      public static StoredScriptSource fromXContent(org.elasticsearch.common.xcontent.XContentParser parser, boolean ignoreEmpty)
      This will parse XContent into a StoredScriptSource. The following format is what will be parsed: { "script" : { "lang" : "<lang>", "source" : "<source>", "options" : { "option0" : "<option0>", "option1" : "<option1>", ... } } } Note that the "source" parameter can also handle template parsing including from a complex JSON object.
      Parameters:
      ignoreEmpty - Specify as true to ignoreEmpty the empty source check. This allows empty templates to be loaded for backwards compatibility.
    • readDiffFrom

      public static Diff<StoredScriptSource> readDiffFrom(StreamInput in) throws
      Required for ScriptMetadata.ScriptMetadataDiff. Uses the StoredScriptSource(StreamInput) constructor.
      Throws:
    • writeTo

      public void writeTo(StreamOutput out) throws
      Writes a StoredScriptSource to a stream. Will write all of the lang, source, and options parameters.
      Specified by:
      writeTo in interface Writeable
      Throws:
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws
      This will write XContent from a StoredScriptSource. The following format will be written: { "script" : { "lang" : "<lang>", "source" : "<source>", "options" : { "option0" : "<option0>", "option1" : "<option1>", ... } } } Note that the 'source' parameter can also handle templates written as complex JSON.
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
    • getLang

      public  getLang()
      Returns:
      The language used for compiling this script.
    • getSource

      public  getSource()
      Returns:
      The source used for compiling this script.
    • getOptions

      public <,​> getOptions()
      Returns:
      The compiler options used for this script.
    • equals

      public boolean equals( o)
      Overrides:
       in class 
    • hashCode

      public int hashCode()
      Overrides:
       in class 
    • toString

      public  toString()
      Overrides:
       in class