|
19 | 19 |
|
20 | 20 | package org.elasticsearch.action.update;
|
21 | 21 |
|
22 |
| -import java.io.IOException; |
23 |
| -import java.util.HashMap; |
24 |
| -import java.util.Map; |
25 |
| -import java.util.function.LongSupplier; |
26 | 22 | import org.apache.logging.log4j.Logger;
|
27 | 23 | import org.elasticsearch.ElasticsearchException;
|
28 | 24 | import org.elasticsearch.action.DocWriteResponse;
|
|
53 | 49 | import org.elasticsearch.script.UpdateScript;
|
54 | 50 | import org.elasticsearch.search.lookup.SourceLookup;
|
55 | 51 |
|
| 52 | +import java.io.IOException; |
56 | 53 | import java.util.ArrayList;
|
57 |
| -import static org.elasticsearch.common.Booleans.parseBoolean; |
| 54 | +import java.util.HashMap; |
| 55 | +import java.util.Map; |
| 56 | +import java.util.function.LongSupplier; |
58 | 57 |
|
59 | 58 | /**
|
60 | 59 | * Helper for translating an update request to an index, delete request or update response.
|
61 | 60 | */
|
62 | 61 | public class UpdateHelper extends AbstractComponent {
|
63 | 62 |
|
64 |
| - /** Whether scripts should add the ctx variable to the params map. */ |
65 |
| - private static final boolean CTX_IN_PARAMS = |
66 |
| - parseBoolean(System.getProperty("es.scripting.update.ctx_in_params"), true); |
67 |
| - |
68 | 63 | private final ScriptService scriptService;
|
69 | 64 |
|
70 | 65 | public UpdateHelper(Settings settings, ScriptService scriptService) {
|
@@ -304,17 +299,8 @@ private Map<String, Object> executeScript(Script script, Map<String, Object> ctx
|
304 | 299 | try {
|
305 | 300 | if (scriptService != null) {
|
306 | 301 | UpdateScript.Factory factory = scriptService.compile(script, UpdateScript.CONTEXT);
|
307 |
| - final Map<String, Object> params; |
308 |
| - if (CTX_IN_PARAMS) { |
309 |
| - params = new HashMap<>(script.getParams()); |
310 |
| - params.put(ContextFields.CTX, ctx); |
311 |
| - deprecationLogger.deprecated("Using `ctx` via `params.ctx` is deprecated. " + |
312 |
| - "Use -Des.scripting.update.ctx_in_params=false to enforce non-deprecated usage."); |
313 |
| - } else { |
314 |
| - params = script.getParams(); |
315 |
| - } |
316 |
| - UpdateScript executableScript = factory.newInstance(params); |
317 |
| - executableScript.execute(ctx); |
| 302 | + UpdateScript executableScript = factory.newInstance(script.getParams(), ctx); |
| 303 | + executableScript.execute(); |
318 | 304 | }
|
319 | 305 | } catch (Exception e) {
|
320 | 306 | throw new IllegalArgumentException("failed to execute script", e);
|
|
0 commit comments