小编hom*_*boy的帖子

使用数组方法 unique() 更新脚本导致错误

我需要用另一个数组更新数组值,然后删除交集,所以我发现这个方法“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)

elasticsearch

2
推荐指数
1
解决办法
853
查看次数

解析错误的 JSON

我使用 JSON 将数据发送到 websocket。有时 websocket 将许多消息作为一个接收,而 event.data 看起来像:

{"message1":"message1"}{"message2":"message2"}
Run Code Online (Sandbox Code Playgroud)

所以我无法用 JSON.Parse 解析它。如何处理这个问题?

javascript jquery json websocket

1
推荐指数
1
解决办法
962
查看次数

标签 统计

elasticsearch ×1

javascript ×1

jquery ×1

json ×1

websocket ×1