我有一个Elasticsearch文件{
"_index": "testindex",
"_type": "testtype",
"_id": "doc1",
"_version": 1,
"found": true,
"_source": {
"array": [
"abc",
"def",
"ghi"
]
}
}
如何反转文档中数组内部的所有字符串?我尝试通过以下脚本使用更新APItemp = []; for(String item : ctx._source.array) temp << item.reverse(); ctx._source.array = temp;
更新Java中的api:
new org.elasticsearch.action.update.UpdateRequest(index, type, docId).script(script);
我在脚本中收到不允许进行方法调用之类的异常。
Bulk request failure, id: [doc4], message: ElasticsearchIllegalArgumentException[failed to execute script]; nested: GroovyScriptCompilationException[MultipleCompilationErrorsException[startup failed:
General error during canonicalization: Method calls not allowed on [java.lang.String]
最佳答案
关于elasticsearch - 如何使用常规脚本反转Elasticsearch文档中数组内的所有字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37391474/