Skip to content

Commit 44cbbe3

Browse files
authored
Remove ingest conditionals _type deprecation warning (#134851)
1 parent 8d66cd5 commit 44cbbe3

File tree

3 files changed

+6
-67
lines changed

3 files changed

+6
-67
lines changed

docs/changelog/134851.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 134851
2+
summary: Remove ingest conditionals `_type` deprecation warning
3+
area: Ingest Node
4+
type: enhancement
5+
issues: []

server/src/main/java/org/elasticsearch/ingest/ConditionalProcessor.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
package org.elasticsearch.ingest;
1111

12-
import org.elasticsearch.common.logging.DeprecationCategory;
13-
import org.elasticsearch.common.logging.DeprecationLogger;
14-
import org.elasticsearch.script.DynamicMap;
1512
import org.elasticsearch.script.IngestConditionalScript;
1613
import org.elasticsearch.script.Script;
1714
import org.elasticsearch.script.ScriptException;
@@ -28,7 +25,6 @@
2825
import java.util.Map;
2926
import java.util.Set;
3027
import java.util.function.BiConsumer;
31-
import java.util.function.Function;
3228
import java.util.function.LongSupplier;
3329
import java.util.stream.Collectors;
3430

@@ -39,16 +35,6 @@
3935
*/
4036
public class ConditionalProcessor extends AbstractProcessor implements WrappingProcessor {
4137

42-
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class);
43-
private static final Map<String, Function<Object, Object>> FUNCTIONS = Map.of("_type", value -> {
44-
deprecationLogger.warn(
45-
DeprecationCategory.INDICES,
46-
"conditional-processor__type",
47-
"[types removal] Looking up doc types [_type] in scripts is deprecated."
48-
);
49-
return value;
50-
});
51-
5238
static final String TYPE = "conditional";
5339

5440
private final Script condition;
@@ -144,10 +130,7 @@ boolean evaluate(IngestDocument ingestDocument) {
144130
if (factory == null) {
145131
factory = scriptService.compile(condition, IngestConditionalScript.CONTEXT);
146132
}
147-
return factory.newInstance(
148-
condition.getParams(),
149-
new UnmodifiableIngestData(new DynamicMap(ingestDocument.getSourceAndMetadata(), FUNCTIONS))
150-
).execute();
133+
return factory.newInstance(condition.getParams(), new UnmodifiableIngestData(ingestDocument.getSourceAndMetadata())).execute();
151134
}
152135

153136
public Processor getInnerProcessor() {

server/src/test/java/org/elasticsearch/ingest/ConditionalProcessorTests.java

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -143,55 +143,6 @@ public void testActsOnImmutableData() throws Exception {
143143
assertMutatingCtxThrows(ctx -> ((List<Object>) ctx.get("listField")).remove("bar"));
144144
}
145145

146-
public void testTypeDeprecation() throws Exception {
147-
148-
ScriptService scriptService = new ScriptService(
149-
Settings.builder().build(),
150-
Map.of(Script.DEFAULT_SCRIPT_LANG, new MockScriptEngine(Script.DEFAULT_SCRIPT_LANG, Map.of(scriptName, ctx -> {
151-
ctx.get("_type");
152-
return true;
153-
}), Map.of())),
154-
new HashMap<>(ScriptModule.CORE_CONTEXTS),
155-
() -> 1L,
156-
TestProjectResolvers.singleProject(randomProjectIdOrDefault())
157-
);
158-
159-
LongSupplier relativeTimeProvider = mock(LongSupplier.class);
160-
when(relativeTimeProvider.getAsLong()).thenReturn(0L, TimeUnit.MILLISECONDS.toNanos(1), 0L, TimeUnit.MILLISECONDS.toNanos(2));
161-
ConditionalProcessor processor = new ConditionalProcessor(
162-
randomAlphaOfLength(10),
163-
"description",
164-
new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, scriptName, Map.of()),
165-
scriptService,
166-
new Processor() {
167-
@Override
168-
public IngestDocument execute(final IngestDocument ingestDocument) {
169-
return ingestDocument;
170-
}
171-
172-
@Override
173-
public String getType() {
174-
return null;
175-
}
176-
177-
@Override
178-
public String getTag() {
179-
return null;
180-
}
181-
182-
@Override
183-
public String getDescription() {
184-
return null;
185-
}
186-
},
187-
relativeTimeProvider
188-
);
189-
190-
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Map.of());
191-
execProcessor(processor, ingestDocument, (result, e) -> {});
192-
assertWarnings("[types removal] Looking up doc types [_type] in scripts is deprecated.");
193-
}
194-
195146
public void testPrecompiledError() {
196147
ScriptService scriptService = MockScriptService.singleContext(IngestConditionalScript.CONTEXT, code -> {
197148
throw new ScriptException("bad script", new ParseException("error", 0), List.of(), "", "lang", null);

0 commit comments

Comments
 (0)