Skip to content

[BUG] dynamic method [java.lang.String, sha256/0] not available in _reindex Painless script #16423

@dkvasnicka

Description

@dkvasnicka

Describe the bug

When executing a _reindex call during which I want to use a script to change the ID of each document I'm getting:

{
  "error": {
    "root_cause": [
      {
        "type": "script_exception",
        "reason": "runtime error",
        "script_stack": [
          "ctx._id = ctx._source.url.sha256()",
          "                         ^---- HERE"
        ],
        "script": "ctx._id = ctx._source.url.sha256()",
        "lang": "painless",
        "position": {
          "offset": 25,
          "start": 0,
          "end": 34
        }
      }
    ],
    "type": "script_exception",
    "reason": "runtime error",
    "script_stack": [
      "ctx._id = ctx._source.url.sha256()",
      "                         ^---- HERE"
    ],
    "script": "ctx._id = ctx._source.url.sha256()",
    "lang": "painless",
    "position": {
      "offset": 25,
      "start": 0,
      "end": 34
    },
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "dynamic method [java.lang.String, sha256/0] not found"
    }
  },
  "status": 400
}

This was supposedly fixed in ES this April (no associated PR as of now): elastic/elasticsearch#107556

My AWS console says an upgrade to 2.15 is available so if this is no longer an issue in this version please let me know 🙏

Related component

Indexing

To Reproduce

POST /_reindex
{
   "source":{
      "index":"src"
   },
   "dest":{
      "index":"dest"
   },
   "script":{
      "lang":"painless",
      "source":"ctx._id = ctx._source.url.sha256()"
   }
}

Expected behavior

Source index is fully reindexed into the dest index with ID of each document being equal to SHA-256 of the selected String field.

Additional Details

Host/Environment (please complete the following information):
Amazon OpenSearch Service
OpenSearch 2.13
OpenSearch_2_13_R20240520-P5

Metadata

Metadata

Assignees

No one assigned

    Labels

    IndexingIndexing, Bulk Indexing and anything related to indexingenhancementEnhancement or improvement to existing feature or requestv2.19.0Issues and PRs related to version 2.19.0v3.0.0Issues and PRs related to version 3.0.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions