- Notifications
You must be signed in to change notification settings - Fork 25.5k
Remove ingest conditionals _type deprecation warning #134851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove ingest conditionals _type deprecation warning #134851
Conversation
from conditional processor scripts
Pinging @elastic/es-data-management (Team:Data Management) |
Hi @joegallo, I've created a changelog YAML for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
private static final Map<String, Function<Object, Object>> FUNCTIONS = Map.of("_type", value -> { | ||
deprecationLogger.warn( | ||
DeprecationCategory.INDICES, | ||
"conditional-processor__type", | ||
"[types removal] Looking up doc types [_type] in scripts is deprecated." | ||
); | ||
return value; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we wouldn't do:
FUNCTIONS = Map.of("_type", ignored -> "_doc");
and just hardcode it to return _doc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess would be because it already does that in Painless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'd be a change in the behavior. The behavior has been (for a while, I could track down the PR that changed it, but I'm 95% sure I didn't write it so I don't know what I'm looking for off the top of my head) that the _type
is null
(in both the conditional and the ordinary script context):
POST _ingest/pipeline/_simulate { "pipeline": { "processors": [ { "script": { "source": "ctx.type_from_script = ctx._type" } }, { "script": { "if": "ctx._type == null", "source": "ctx.type_from_conditional_was_null = true" } } ] }, "docs": [ { "_index": "index", "_id": "id", "_source": { "hello": "world" } } ] }
results in:
{ "docs" : [ { "doc" : { "_index" : "index", "_version" : "-3", "_id" : "id", "_source" : { "type_from_script" : null, "type_from_conditional_was_null" : true, "hello" : "world" }, "_ingest" : { "timestamp" : "2025-09-17T11:33:43.056173Z" } } } ] }
Before and after this PR the above script works the same (that is, _type
is null
), it's just that prior to this PR a deprecation would be generated only for the conditional part of the one script. All this PR does is remove the deprecation warning, other than that doesn't change the behavior of the scripts in question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't found a PR that clearly is the one that makes the _type
be null
for these, but I have confirmed that if you run 8.0.0 the behavior is the same as I show above. So this has been the behavior since at least February 2022.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh okay, I hadn't realized it was null, so removing it makes sense. Thanks for the clarification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
BASE=f6967fec35dafe147432f1259d7a2b7cf29b1d68 HEAD=ba5d8ae076c5643a926506259ee289d5ab7993db Branch=main
BASE=f6967fec35dafe147432f1259d7a2b7cf29b1d68 HEAD=ba5d8ae076c5643a926506259ee289d5ab7993db Branch=main
BASE=f6967fec35dafe147432f1259d7a2b7cf29b1d68 HEAD=ba5d8ae076c5643a926506259ee289d5ab7993db Branch=main
_type
isn't special in ingest conditional scripts anymore, and we shouldn't warn about it as if it is.With this pipeline:
This
_simulate
call:gives this result on
main
:The result would be the same after this PR, there just wouldn't be a warning anymore -- that is,
_type
is just a regular old non-special field, like_foo
or_bar
or whatever (edit: that is, at least in terms of reads).Related to #134816, in that I'm pulling a part of that out as its own PR for searchability and accounting purposes.