我需要用另一个数组更新数组值,然后删除交集,所以我发现这个方法“unique()”适用于elasticsearch脚本,但它导致错误:
{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[probook][127.0.0.1:9300][indices:data/write/update[s]]"
}
],
"type": "illegal_argument_exception",
"reason": "failed to execute script",
"caused_by": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.arrFieldName = ctx._source.arrFieldName.unique();",
" ^---- HERE"
],
"script": "ctx._source.arrFieldName.addAll([111, 222, 333]);ctx._source.arrFieldName = ctx._source.arrFieldName.unique();ctx._source.arrFieldNameCount = ctx._source.arrFieldName.length",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "dynamic method [java.util.ArrayList, unique/0] not found"
}
}
},
"status": 400
}
Run Code Online (Sandbox Code Playgroud) 我使用 JSON 将数据发送到 websocket。有时 websocket 将许多消息作为一个接收,而 event.data 看起来像:
{"message1":"message1"}{"message2":"message2"}
Run Code Online (Sandbox Code Playgroud)
所以我无法用 JSON.Parse 解析它。如何处理这个问题?