-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Core/Infra/ScriptingScripting abstractions, Painless, and MustacheScripting abstractions, Painless, and Mustache>bugTeam:Core/InfraMeta label for core/infra teamMeta label for core/infra teamv8.3.1
Description
Elasticsearch Version
8.3.1
Installed Plugins
No response
Java Version
openjdk version "11.0.22" 2024-01-16 LTS OpenJDK Runtime Environment Corretto-11.0.22.7.1 (build 11.0.22+7-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.22.7.1 (build 11.0.22+7-LTS, mixed mode)
OS Version
Linux user 6.5.0-27-generic #28~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 15 10:51:06 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Problem Description
I try to reindex with script:
{
"source": {
"index": "my-index-1"
},
"dest": {
"index": "my-index-2"
},
"script": {
"lang": "painless",
"source": "if (ctx._source != null) {for (int i = 0; i < ctx._source.arr.length; i++) {if (ctx._source.arr[i].value != null) {ctx._source.arr[i].hash = ctx._source.arr[i].value.sha256();}}}"
}
}
But I got this error:
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.arr[i].hash = ctx._source.arr[i].value.sha256();}}}",
" ^---- HERE"
],
"script": "if (ctx._source != null) {for (int i = 0; i < ctx._source.arr.length; i++) {if (ctx._source.arr[i].value != null) {ctx._source.arr[i].hash = ctx._source.arr[i].value.sha256();}}}",
"lang": "painless",
"position": {
"offset": 177,
"start": 121,
"end": 190
}
}
],
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.arr[i].hash = ctx._source.arr[i].value.sha256();}}}",
" ^---- HERE"
],
"script": "if (ctx._source != null) {for (int i = 0; i < ctx._source.arr.length; i++) {if (ctx._source.arr[i].value != null) {ctx._source.arr[i].hash = ctx._source.arr[i].value.sha256();}}}",
"lang": "painless",
"position": {
"offset": 177,
"start": 121,
"end": 190
},
"caused_by": {
"type": "illegal_argument_exception",
"reason": "dynamic method [java.lang.String, sha256/0] not found"
}
},
"status": 400
}
Do you have any suggestions for what the problem might be?
Steps to Reproduce
Create index my-index-1:
{
"settings": {
"index": {
"number_of_shards": "48",
"number_of_replicas": "1",
"refresh_interval": "30000s"
}
},
"mappings": {
"dynamic": "strict",
"properties": {
"arr": {
"properties": {
"value": {
"type": "text"
}
}
}
}
}
}
Create index my-index-2:
{
"settings": {
"index": {
"number_of_shards": "48",
"number_of_replicas": "1",
"refresh_interval": "30000s"
}
},
"mappings": {
"dynamic": "strict",
"properties": {
"arr": {
"properties": {
"value": {
"type": "text"
},
"hash": {
"type": "text"
}
}
}
}
}
}
Add some values and try to reindex with script.
Logs (if relevant)
No response
Metadata
Metadata
Assignees
Labels
:Core/Infra/ScriptingScripting abstractions, Painless, and MustacheScripting abstractions, Painless, and Mustache>bugTeam:Core/InfraMeta label for core/infra teamMeta label for core/infra teamv8.3.1