Skip to content

Conversation

@phananh1010
Copy link
Owner

_type isn't special in ingest conditional scripts anymore, and we shouldn't warn about it as if it is.

With this pipeline:

PUT _ingest/pipeline/underscore_type
{
  "processors": [
    {
      "script": {
        "source": "ctx._foo = ctx._bar"  # this is a field
      }
    },
    {
      "script": {
        "source": "ctx._baz = ctx._type" # no warning from this, it's not a _conditional_
      }
    },
    {
      "set": {
        "if": "ctx._type == null", # this warns on `main` but won't anymore after this PR
        "field": "message_1",
        "value": "test"
      }
    },
    {
      "set": {
        "if": "ctx._missing == null", # this is just another field
        "field": "message_2",
        "value": "some other test"
      }
    }
  ]
}

This _simulate call:

POST _ingest/pipeline/underscore_type/_simulate
{
  "docs": [
    {
      "_index": "index",
      "_id": "id",
      "_source": {
        "hello": "world",
        "_bar": "quux"
      }
    }
  ]
}

gives this result on main:

// Warning: 299 Elasticsearch-9.2.0-494dc7075a299cb5edb06c36681601550c4fcdae "[types removal] Looking up doc types [_type] in scripts is deprecated."
{
  "docs" : [
    {
      "doc" : {
        "_index" : "index",
        "_version" : "-3",
        "_id" : "id",
        "_source" : {
          "_baz" : null,
          "message_2" : "some other test",
          "message_1" : "test",
          "_bar" : "quux",
          "hello" : "world",
          "_foo" : "quux"
        },
        "_ingest" : {
          "timestamp" : "2025-09-16T21:36:01.143913Z"
        }
      }
    }
  ]
}

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 elastic#134816, in that I'm pulling a part of that out as its own PR for searchability and accounting purposes.

BASE=f6967fec35dafe147432f1259d7a2b7cf29b1d68
HEAD=ba5d8ae076c5643a926506259ee289d5ab7993db
Branch=main
@phananh1010
Copy link
Owner Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants