summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/olivere/elastic.v5/script.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/script.go')
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/script.go26
1 files changed, 11 insertions, 15 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/script.go b/vendor/gopkg.in/olivere/elastic.v5/script.go
index b771c0547..273473950 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/script.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/script.go
@@ -9,7 +9,7 @@ import "errors"
// Script holds all the paramaters necessary to compile or find in cache
// and then execute a script.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/modules-scripting.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/modules-scripting.html
// for details of scripting.
type Script struct {
script string
@@ -22,26 +22,21 @@ type Script struct {
func NewScript(script string) *Script {
return &Script{
script: script,
- typ: "", // default type is "inline"
+ typ: "inline",
params: make(map[string]interface{}),
}
}
-// NewScriptInline creates and initializes a new Script of type "inline".
+// NewScriptInline creates and initializes a new inline script, i.e. code.
func NewScriptInline(script string) *Script {
return NewScript(script).Type("inline")
}
-// NewScriptId creates and initializes a new Script of type "id".
-func NewScriptId(script string) *Script {
+// NewScriptStored creates and initializes a new stored script.
+func NewScriptStored(script string) *Script {
return NewScript(script).Type("id")
}
-// NewScriptFile creates and initializes a new Script of type "file".
-func NewScriptFile(script string) *Script {
- return NewScript(script).Type("file")
-}
-
// Script is either the cache key of the script to be compiled/executed
// or the actual script source code for inline scripts. For indexed
// scripts this is the id used in the request. For file scripts this is
@@ -51,7 +46,7 @@ func (s *Script) Script(script string) *Script {
return s
}
-// Type sets the type of script: "inline", "id", or "file".
+// Type sets the type of script: "inline" or "id".
func (s *Script) Type(typ string) *Script {
s.typ = typ
return s
@@ -60,7 +55,7 @@ func (s *Script) Type(typ string) *Script {
// Lang sets the language of the script. Permitted values are "groovy",
// "expression", "mustache", "mvel" (default), "javascript", "python".
// To use certain languages, you need to configure your server and/or
-// add plugins. See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/modules-scripting.html
+// add plugins. See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/modules-scripting.html
// for details.
func (s *Script) Lang(lang string) *Script {
s.lang = lang
@@ -88,10 +83,11 @@ func (s *Script) Source() (interface{}, error) {
return s.script, nil
}
source := make(map[string]interface{})
- if s.typ == "" {
- source["inline"] = s.script
+ // Beginning with 6.0, the type can only be "source" or "id"
+ if s.typ == "" || s.typ == "inline" {
+ source["source"] = s.script
} else {
- source[s.typ] = s.script
+ source["id"] = s.script
}
if s.lang != "" {
source["lang"] = s.lang