diff --git a/docs/plugins/lang-javascript.asciidoc b/docs/plugins/lang-javascript.asciidoc index 41fbaed3c38..48cf9763500 100644 --- a/docs/plugins/lang-javascript.asciidoc +++ b/docs/plugins/lang-javascript.asciidoc @@ -1,6 +1,8 @@ [[lang-javascript]] === JavaScript Language Plugin +deprecated[5.0.0,Javascript will be replaced by the new scripting language <>] + The JavaScript language plugin enables the use of JavaScript in Elasticsearch scripts, via Mozilla's https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino[Rhino JavaScript] engine. diff --git a/docs/plugins/lang-python.asciidoc b/docs/plugins/lang-python.asciidoc index 96d00d9e2c8..4ad0fe628cb 100644 --- a/docs/plugins/lang-python.asciidoc +++ b/docs/plugins/lang-python.asciidoc @@ -1,6 +1,8 @@ [[lang-python]] === Python Language Plugin +deprecated[5.0.0,Python will be replaced by the new scripting language <>] + The Python language plugin enables the use of Python in Elasticsearch scripts, via the http://www.jython.org/[Jython] Java implementation of Python. diff --git a/docs/reference/modules/scripting.asciidoc b/docs/reference/modules/scripting.asciidoc index 76065210569..253fab3941b 100644 --- a/docs/reference/modules/scripting.asciidoc +++ b/docs/reference/modules/scripting.asciidoc @@ -5,12 +5,7 @@ The scripting module enables you to use scripts to evaluate custom expressions. For example, you could use a script to return "script fields" as part of a search request or evaluate a custom score for a query. -TIP: Elasticsearch now has a built-in scripting language called _Painless_ -that provides a more secure alternative for implementing -scripts for Elasticsearch. We encourage you to try it out -- -for more information, see <>. - -The default scripting language is http://groovy-lang.org/[groovy]. +The default scripting language is <>. Additional `lang` plugins enable you to run scripts written in other languages. Everywhere a script can be used, you can include a `lang` parameter to specify the language of the script. diff --git a/docs/reference/modules/scripting/groovy.asciidoc b/docs/reference/modules/scripting/groovy.asciidoc index 07551474e2c..aaacd85f243 100644 --- a/docs/reference/modules/scripting/groovy.asciidoc +++ b/docs/reference/modules/scripting/groovy.asciidoc @@ -1,6 +1,8 @@ [[modules-scripting-groovy]] === Groovy Scripting Language +deprecated[5.0.0,Groovy will be replaced by the new scripting language <>] + Groovy is the default scripting language available in Elasticsearch. Although limited by the <>, it is not a sandboxed language and only `file` scripts may be used by default. diff --git a/modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java b/modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java index 6216ec2354e..923219d908a 100644 --- a/modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java +++ b/modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java @@ -68,6 +68,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; import static java.util.Collections.emptyList; @@ -91,6 +92,11 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri */ private final ClassLoader loader; + /** + * Ensures that the deprecation log entry for Groovy is only written on the first Groovy script compiled. + */ + private AtomicBoolean isDeprecationLogged = new AtomicBoolean(false); + public GroovyScriptEngineService(Settings settings) { super(settings); // Creates the classloader here in order to isolate Groovy-land code @@ -134,6 +140,10 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri @Override public Object compile(String scriptName, String scriptSource, Map params) { + if (isDeprecationLogged.compareAndSet(false, true)) { + deprecationLogger.deprecated("Groovy scripts are deprecated. Use Painless scripts instead."); + } + // Create the script class name String className = MessageDigests.toHexString(MessageDigests.sha1().digest(scriptSource.getBytes(StandardCharsets.UTF_8))); diff --git a/plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java b/plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java index 3477f62a5bc..d418e9877c7 100644 --- a/plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java +++ b/plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java @@ -25,6 +25,7 @@ import org.elasticsearch.SpecialPermission; import org.elasticsearch.bootstrap.BootstrapInfo; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.component.AbstractComponent; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.script.ClassPermission; import org.elasticsearch.script.CompiledScript; @@ -138,6 +139,8 @@ public class JavaScriptScriptEngineService extends AbstractComponent implements public JavaScriptScriptEngineService(Settings settings) { super(settings); + deprecationLogger.deprecated("Javascript scripts are deprecated. Use Painless scripts instead."); + Context ctx = Context.enter(); try { globalScope = ctx.initStandardObjects(null, true); diff --git a/plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java b/plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java index 5a16c06d4dc..69ff2ffe70f 100644 --- a/plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java +++ b/plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java @@ -62,6 +62,8 @@ public class PythonScriptEngineService extends AbstractComponent implements Scri public PythonScriptEngineService(Settings settings) { super(settings); + deprecationLogger.deprecated("Python scripts are deprecated. Use Painless scripts instead."); + // classloader created here final SecurityManager sm = System.getSecurityManager(); if (sm != null) {