summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/script/ScriptTests.java
diff options
context:
space:
mode:
authorJack Conradson <osjdconrad@gmail.com>2017-01-31 13:27:02 -0800
committerGitHub <noreply@github.com>2017-01-31 13:27:02 -0800
commit3d2626c4c694db0abd1ad15badecd75a06818f40 (patch)
tree3bf18ef971cfcbf84798753e4b886b02e68ea0dd /core/src/test/java/org/elasticsearch/script/ScriptTests.java
parenteb36b82de48750777172ecdc3b019de32535e3f4 (diff)
Change Namespace for Stored Script to Only Use Id (#22206)
Currently, stored scripts use a namespace of (lang, id) to be put, get, deleted, and executed. This is not necessary since the lang is stored with the stored script. A user should only have to specify an id to use a stored script. This change makes that possible while keeping backwards compatibility with the previous namespace of (lang, id). Anywhere the previous namespace is used will log deprecation warnings. The new behavior is the following: When a user specifies a stored script, that script will be stored under both the new namespace and old namespace. Take for example script 'A' with lang 'L0' and data 'D0'. If we add script 'A' to the empty set, the scripts map will be ["A" -- D0, "A#L0" -- D0]. If a script 'A' with lang 'L1' and data 'D1' is then added, the scripts map will be ["A" -- D1, "A#L1" -- D1, "A#L0" -- D0]. When a user deletes a stored script, that script will be deleted from both the new namespace (if it exists) and the old namespace. Take for example a scripts map with {"A" -- D1, "A#L1" -- D1, "A#L0" -- D0}. If a script is removed specified by an id 'A' and lang null then the scripts map will be {"A#L0" -- D0}. To remove the final script, the deprecated namespace must be used, so an id 'A' and lang 'L0' would need to be specified. When a user gets/executes a stored script, if the new namespace is used then the script will be retrieved/executed using only 'id', and if the old namespace is used then the script will be retrieved/executed using 'id' and 'lang'
Diffstat (limited to 'core/src/test/java/org/elasticsearch/script/ScriptTests.java')
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptTests.java5
1 files changed, 2 insertions, 3 deletions
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptTests.java b/core/src/test/java/org/elasticsearch/script/ScriptTests.java
index 19c8467486..fc841bd164 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptTests.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptTests.java
@@ -78,10 +78,9 @@ public class ScriptTests extends ESTestCase {
}
return new Script(
scriptType,
- randomFrom("_lang1", "_lang2", "_lang3"),
+ scriptType == ScriptType.STORED ? null : randomFrom("_lang1", "_lang2", "_lang3"),
script,
- scriptType == ScriptType.INLINE ?
- Collections.singletonMap(Script.CONTENT_TYPE_OPTION, xContent.type().mediaType()) : Collections.emptyMap(),
+ scriptType == ScriptType.INLINE ? Collections.singletonMap(Script.CONTENT_TYPE_OPTION, xContent.type().mediaType()) : null,
params
);
}