MCPcopy Create free account
hub / github.com/olivere/elastic / rawScriptSource

Method rawScriptSource

script.go:114–121  ·  view source on GitHub ↗

rawScriptSource returns an embeddable script. If it uses a short script form, e.g. "ctx._source.likes++" (without the quotes), it is quoted. Otherwise it returns the raw script that will be directly embedded into the JSON data.

(script string)

Source from the content-addressed store, hash-verified

112// is quoted. Otherwise it returns the raw script that will be directly
113// embedded into the JSON data.
114func (s *Script) rawScriptSource(script string) (interface{}, error) {
115 v := strings.TrimSpace(script)
116 if !strings.HasPrefix(v, "{") && !strings.HasPrefix(v, `"`) {
117 v = fmt.Sprintf("%q", v)
118 }
119 raw := json.RawMessage(v)
120 return &raw, nil
121}
122
123// -- Script Field --
124

Callers 1

SourceMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected