diff --git a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ScriptProcessor.java b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ScriptProcessor.java index f2568826fa484..960ab25c72288 100644 --- a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ScriptProcessor.java +++ b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ScriptProcessor.java @@ -34,7 +34,6 @@ import org.opensearch.common.Nullable; import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.util.CollectionUtils; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.NamedXContentRegistry; @@ -45,7 +44,6 @@ import org.opensearch.ingest.AbstractProcessor; import org.opensearch.ingest.IngestDocument; import org.opensearch.ingest.Processor; -import org.opensearch.script.DynamicMap; import org.opensearch.script.IngestScript; import org.opensearch.script.Script; import org.opensearch.script.ScriptException; @@ -55,7 +53,6 @@ import java.io.InputStream; import java.util.Arrays; import java.util.Map; -import java.util.function.Function; import static org.opensearch.ingest.ConfigurationUtils.newConfigurationException; @@ -64,12 +61,6 @@ */ public final class ScriptProcessor extends AbstractProcessor { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); - private static final Map> PARAMS_FUNCTIONS = org.opensearch.common.collect.Map.of("_type", value -> { - deprecationLogger.deprecate("script_processor", "[types removal] Looking up doc types [_type] in scripts is deprecated."); - return value; - }); - public static final String TYPE = "script"; private final Script script; @@ -111,7 +102,7 @@ public IngestDocument execute(IngestDocument document) { } else { ingestScript = precompiledIngestScript; } - ingestScript.execute(new DynamicMap(document.getSourceAndMetadata(), PARAMS_FUNCTIONS)); + ingestScript.execute(document.getSourceAndMetadata()); CollectionUtils.ensureNoSelfReferences(document.getSourceAndMetadata(), "ingest script"); return document; } diff --git a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/ScriptProcessorTests.java b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/ScriptProcessorTests.java index 1aa4898441598..96d9be75c4ab7 100644 --- a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/ScriptProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/ScriptProcessorTests.java @@ -105,24 +105,4 @@ private void assertIngestDocument(IngestDocument ingestDocument) { int bytesTotal = ingestDocument.getFieldValue("bytes_in", Integer.class) + ingestDocument.getFieldValue("bytes_out", Integer.class); assertThat(ingestDocument.getSourceAndMetadata().get("bytes_total"), is(bytesTotal)); } - - public void testTypeDeprecation() throws Exception { - String scriptName = "script"; - ScriptService scriptService = new ScriptService( - Settings.builder().build(), - Collections.singletonMap( - Script.DEFAULT_SCRIPT_LANG, - new MockScriptEngine(Script.DEFAULT_SCRIPT_LANG, Collections.singletonMap(scriptName, ctx -> { - ctx.get("_type"); - return null; - }), Collections.emptyMap()) - ), - new HashMap<>(ScriptModule.CORE_CONTEXTS) - ); - Script script = new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, scriptName, Collections.emptyMap()); - IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); - ScriptProcessor processor = new ScriptProcessor(randomAlphaOfLength(10), null, script, null, scriptService); - processor.execute(ingestDocument); - assertWarnings("[types removal] Looking up doc types [_type] in scripts is deprecated."); - } } diff --git a/server/src/main/java/org/opensearch/ingest/ConditionalProcessor.java b/server/src/main/java/org/opensearch/ingest/ConditionalProcessor.java index 7d4a2b32fbb5f..591a71fd72b8f 100644 --- a/server/src/main/java/org/opensearch/ingest/ConditionalProcessor.java +++ b/server/src/main/java/org/opensearch/ingest/ConditionalProcessor.java @@ -32,8 +32,6 @@ package org.opensearch.ingest; -import org.opensearch.common.logging.DeprecationLogger; -import org.opensearch.script.DynamicMap; import org.opensearch.script.IngestConditionalScript; import org.opensearch.script.Script; import org.opensearch.script.ScriptException; @@ -51,7 +49,6 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; -import java.util.function.Function; import java.util.function.LongSupplier; import java.util.stream.Collectors; @@ -64,15 +61,6 @@ */ public class ConditionalProcessor extends AbstractProcessor implements WrappingProcessor { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); - private static final Map> FUNCTIONS = org.opensearch.common.collect.Map.of("_type", value -> { - deprecationLogger.deprecate( - "conditional-processor__type", - "[types removal] Looking up doc types [_type] in scripts is deprecated." - ); - return value; - }); - static final String TYPE = "conditional"; private final Script condition; @@ -153,7 +141,7 @@ boolean evaluate(IngestDocument ingestDocument) { IngestConditionalScript.Factory factory = scriptService.compile(condition, IngestConditionalScript.CONTEXT); script = factory.newInstance(condition.getParams()); } - return script.execute(new UnmodifiableIngestData(new DynamicMap(ingestDocument.getSourceAndMetadata(), FUNCTIONS))); + return script.execute(new UnmodifiableIngestData(ingestDocument.getSourceAndMetadata())); } public Processor getInnerProcessor() { diff --git a/server/src/main/java/org/opensearch/script/UpdateScript.java b/server/src/main/java/org/opensearch/script/UpdateScript.java index fdceadc03879e..86697e9ae550e 100644 --- a/server/src/main/java/org/opensearch/script/UpdateScript.java +++ b/server/src/main/java/org/opensearch/script/UpdateScript.java @@ -32,10 +32,7 @@ package org.opensearch.script; -import org.opensearch.common.logging.DeprecationLogger; - import java.util.Map; -import java.util.function.Function; /** * An update script. @@ -44,12 +41,6 @@ */ public abstract class UpdateScript { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); - private static final Map> PARAMS_FUNCTIONS = org.opensearch.common.collect.Map.of("_type", value -> { - deprecationLogger.deprecate("update-script", "[types removal] Looking up doc types [_type] in scripts is deprecated."); - return value; - }); - public static final String[] PARAMETERS = {}; /** The context used to compile {@link UpdateScript} factories. */ @@ -63,7 +54,7 @@ public abstract class UpdateScript { public UpdateScript(Map params, Map ctx) { this.params = params; - this.ctx = new DynamicMap(ctx, PARAMS_FUNCTIONS); + this.ctx = ctx; } /** Return the parameters for this script. */ diff --git a/server/src/test/java/org/opensearch/ingest/ConditionalProcessorTests.java b/server/src/test/java/org/opensearch/ingest/ConditionalProcessorTests.java index 2fc734c5abbf2..1550dd65442a4 100644 --- a/server/src/test/java/org/opensearch/ingest/ConditionalProcessorTests.java +++ b/server/src/test/java/org/opensearch/ingest/ConditionalProcessorTests.java @@ -163,56 +163,6 @@ public void testActsOnImmutableData() throws Exception { assertMutatingCtxThrows(ctx -> ((List) ctx.get("listField")).remove("bar")); } - public void testTypeDeprecation() throws Exception { - - ScriptService scriptService = new ScriptService( - Settings.builder().build(), - Collections.singletonMap( - Script.DEFAULT_SCRIPT_LANG, - new MockScriptEngine(Script.DEFAULT_SCRIPT_LANG, Collections.singletonMap(scriptName, ctx -> { - ctx.get("_type"); - return true; - }), Collections.emptyMap()) - ), - new HashMap<>(ScriptModule.CORE_CONTEXTS) - ); - - LongSupplier relativeTimeProvider = mock(LongSupplier.class); - when(relativeTimeProvider.getAsLong()).thenReturn(0L, TimeUnit.MILLISECONDS.toNanos(1), 0L, TimeUnit.MILLISECONDS.toNanos(2)); - ConditionalProcessor processor = new ConditionalProcessor( - randomAlphaOfLength(10), - "description", - new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, scriptName, Collections.emptyMap()), - scriptService, - new Processor() { - @Override - public IngestDocument execute(final IngestDocument ingestDocument) { - return ingestDocument; - } - - @Override - public String getType() { - return null; - } - - @Override - public String getTag() { - return null; - } - - @Override - public String getDescription() { - return null; - } - }, - relativeTimeProvider - ); - - IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); - processor.execute(ingestDocument, (result, e) -> {}); - assertWarnings("[types removal] Looking up doc types [_type] in scripts is deprecated."); - } - public void testPrecompiledError() { ScriptService scriptService = MockScriptService.singleContext( IngestConditionalScript.CONTEXT,