From d2b4f7ac5a387611947962505b437f553059b941 Mon Sep 17 00:00:00 2001 From: Jack Conradson Date: Wed, 12 Jul 2017 07:55:57 -0700 Subject: [PATCH] Disallow lang to be used with Stored Scripts (#25610) Requests that execute a stored script will no longer be allowed to specify the lang of the script. This information is stored in the cluster state making only an id necessary to execute against. Putting a stored script will still require a lang. --- .../documentation/CRUDDocumentationIT.java | 2 +- .../QueryDSLDocumentationTests.java | 2 +- .../java/org/elasticsearch/script/Script.java | 47 +++++++------------ .../elasticsearch/script/ScriptService.java | 38 +++------------ .../script/ScriptServiceTests.java | 28 ++++++----- .../metrics/ScriptedMetricIT.java | 8 ++-- .../aggregations/pipeline/BucketScriptIT.java | 2 +- .../pipeline/BucketSelectorIT.java | 2 +- .../migration/migrate_6_0/scripting.asciidoc | 8 ++++ .../modules/scripting/using.asciidoc | 22 --------- .../ingest/common/ScriptProcessor.java | 2 +- .../common/ScriptProcessorFactoryTests.java | 4 +- .../expression/StoredExpressionTests.java | 6 +-- .../TransportSearchTemplateAction.java | 4 +- .../script/mustache/SearchTemplateIT.java | 22 ++------- .../index/reindex/RoundTripTests.java | 4 +- 16 files changed, 70 insertions(+), 131 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java index db5fcc11bce..e14ee70bec7 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java @@ -283,7 +283,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { request = new UpdateRequest("posts", "doc", "1").fetchSource(true); //tag::update-request-with-stored-script Script stored = - new Script(ScriptType.STORED, "painless", "increment-field", parameters); // <1> + new Script(ScriptType.STORED, null, "increment-field", parameters); // <1> request.script(stored); // <2> //end::update-request-with-stored-script updateResponse = client.update(request); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java index 01a5eb5dfc1..50b30d69348 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java @@ -339,7 +339,7 @@ public class QueryDSLDocumentationTests extends ESTestCase { parameters.put("param1", 5); scriptQuery(new Script( ScriptType.STORED, // <1> - "painless", // <2> + null, // <2> "myscript", // <3> singletonMap("param1", 5))); // <4> // end::script_file diff --git a/core/src/main/java/org/elasticsearch/script/Script.java b/core/src/main/java/org/elasticsearch/script/Script.java index ee4f8e442f4..e3209d0c1f1 100644 --- a/core/src/main/java/org/elasticsearch/script/Script.java +++ b/core/src/main/java/org/elasticsearch/script/Script.java @@ -19,15 +19,12 @@ package org.elasticsearch.script; -import org.apache.logging.log4j.Logger; import org.elasticsearch.Version; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.logging.DeprecationLogger; -import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.ObjectParser.ValueType; import org.elasticsearch.common.xcontent.ToXContentObject; @@ -66,8 +63,7 @@ import java.util.Objects; *
  • {@link ScriptType#STORED} *