elasticsearch - 如何让 Elasticsearch 在一个请求中接受多个 json?
问题描述
我正在使用 Elasticsearch7 并基于https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html创建一个管道。
管道是解码base64,如下所示:
{
"version": 1,
"processors": [
{
"script": {
"source": "ctx.decoded = ctx.data.decodeBase64();"
}
},
{
"json": {
"field": "decoded",
"add_to_root": true
}
},
{
"remove": {
"field": "decoded"
}
}
]
}
将数据推送到索引时收到错误消息:
Response for request ff6dd42a-5694-4c17-b103-c37bae72af58 is not recognized as valid JSON or has unexpected fields. Raw response received: 400 {\"error\":{\"root_cause\":[{\"type\":\"script_exception\",\"reason\":\"runtime error\",\"script_stack\":[\"ctx.decoded = ctx.data.decodeBase64();\",\" ^---- HERE\"],\"script\":\"ctx.decoded = ctx.data.decodeBase64();\",\"lang\":\"painless\",\"position\":{\"offset\":22,\"start\":0,\"end\":38}}],\"type\":\"script_exception\",\"reason\":\"runtime error\",\"script_stack\":[\"ctx.decoded = ctx.data.decodeBase64();\",\" ^---- HERE\"],\"script\":\"ctx.decoded = ctx.data.decodeBase64();\",\"lang\":\"painless\",\"position\":{\"offset\":22,\"start\":0,\"end\":38},\"caused_by\":{\"type\":\"null_pointer_exception\",\"reason\":\"Cannot invoke \\\"Object.getClass()\\\" because \\\"callArgs[0]\\\" is null\"}},\"status\":400}
原因是json不是一个单一的。它是一个多 json 数据:
{
"data": "..."
}
{
"data": "..."
}
它们不是有效的 json 数组,所以我怎样才能让 Elasticsearch piepline 接受这种格式?
解决方案
推荐阅读
- python - 有人可以在 python 中为我解压这一行吗?我对这条线有点困惑
- reactjs - 分支覆盖率没有达到 80%,我不知道为什么
- scheme - 方案允许大写定义
- winapi - Alink (Assembly) - Relocs x: 警告 16 位字段中的 32 位偏移
- python - configparser,将键转换为变量
- reactjs - 当用户键入内容时将文本存储到会话存储中
- keystore - 在 android studio 上更改密钥存储密码
- python-3.x - 我一直在尝试用 python 制作一个 python 蛇游戏,但我不断收到“pygame not initialized”错误
- python - 通过 Python 的 HTTP (REST) 请求
- socket.io - 如何在 4.x 中生成带有套接字 id 的套接字?