Package org.elasticsearch.script
Class StoredScriptSource
java.lang.Object
org.elasticsearch.script.StoredScriptSource
- All Implemented Interfaces:
Diffable<StoredScriptSource>,SimpleDiffable<StoredScriptSource>,Writeable,org.elasticsearch.xcontent.ToXContent,org.elasticsearch.xcontent.ToXContentObject
public class StoredScriptSource
extends Object
implements SimpleDiffable<StoredScriptSource>, Writeable, org.elasticsearch.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.cluster.SimpleDiffable
SimpleDiffable.CompleteDiff<T extends Diffable<T>>Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
org.elasticsearch.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.xcontent.ToXContent.MapParams, org.elasticsearch.xcontent.ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.elasticsearch.xcontent.ParseFieldStandardParseFieldfor lang on the inner level.static final org.elasticsearch.xcontent.ParseFieldStandardParseFieldfor options on the inner level.static final org.elasticsearch.xcontent.ParseFieldStandardParseFieldfor outer level of stored script source.static final org.elasticsearch.xcontent.ParseFieldStandardParseFieldfor source on the inner level.Fields inherited from interface org.elasticsearch.cluster.SimpleDiffable
EMPTYFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionStandard StoredScriptSource constructor.Reads aStoredScriptSourcefrom a stream. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic StoredScriptSourcefromXContent(org.elasticsearch.xcontent.XContentParser parser, boolean ignoreEmpty) This will parse XContent into aStoredScriptSource.getLang()inthashCode()static StoredScriptSourceparse(BytesReference content, org.elasticsearch.xcontent.XContentType xContentType) This will parse XContent into aStoredScriptSource.static Diff<StoredScriptSource>Required forScriptMetadata.ScriptMetadataDiff.toString()org.elasticsearch.xcontent.XContentBuildertoXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) This will write XContent from aStoredScriptSource.voidwriteTo(StreamOutput out) Writes aStoredScriptSourceto a stream.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.cluster.SimpleDiffable
diffMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
SCRIPT_PARSE_FIELD
public static final org.elasticsearch.xcontent.ParseField SCRIPT_PARSE_FIELDStandardParseFieldfor outer level of stored script source. -
LANG_PARSE_FIELD
public static final org.elasticsearch.xcontent.ParseField LANG_PARSE_FIELDStandardParseFieldfor lang on the inner level. -
SOURCE_PARSE_FIELD
public static final org.elasticsearch.xcontent.ParseField SOURCE_PARSE_FIELDStandardParseFieldfor source on the inner level. -
OPTIONS_PARSE_FIELD
public static final org.elasticsearch.xcontent.ParseField OPTIONS_PARSE_FIELDStandardParseFieldfor options on the inner level.
-
-
Constructor Details
-
StoredScriptSource
Standard StoredScriptSource constructor.- Parameters:
lang- The language to compile the script with. Must not benull.source- The source source to compile with. Must not benull.options- Compiler options to be compiled with. Must not benull, use an emptyMapto represent no options.
-
StoredScriptSource
Reads aStoredScriptSourcefrom 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:
IOException
-
-
Method Details
-
parse
public static StoredScriptSource parse(BytesReference content, org.elasticsearch.xcontent.XContentType xContentType) This will parse XContent into aStoredScriptSource. Examples of legal JSON:{ "script" : { "lang" : "<lang>", "source" : "<source>", "options" : { "option0" : "<option0>", "option1" : "<option1>", ... } } }Example:{ "script": { "lang" : "painless", "source" : "return Math.log(doc.popularity) * params.multiplier" } }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.xcontent.XContentParser parser, boolean ignoreEmpty) This will parse XContent into aStoredScriptSource. 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 astrueto ignoreEmpty the empty source check. This allows empty templates to be loaded for backwards compatibility.
-
readDiffFrom
Required forScriptMetadata.ScriptMetadataDiff. Uses theStoredScriptSource(StreamInput)constructor.- Throws:
IOException
-
writeTo
Writes aStoredScriptSourceto a stream. Will write all of the lang, source, and options parameters.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
toXContent
public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException This will write XContent from aStoredScriptSource. 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:
toXContentin interfaceorg.elasticsearch.xcontent.ToXContent- Throws:
IOException
-
getLang
- Returns:
- The language used for compiling this script.
-
getSource
- Returns:
- The source used for compiling this script.
-
getOptions
- Returns:
- The compiler options used for this script.
-
equals
-
hashCode
public int hashCode() -
toString
-