json - 无法批量索引到弹性搜索
问题描述
我有 json 文件,如图所示,
{ "index": { "_index": "volvo", "_type": "user" }}
{"dn": " cn=s,o=VCC\n", "changetype": " add\n", "mail": " com\n", "surname": " s\n", "givenname": " s\n", "cn": " su2\n", "objectclass": [" inetOrgPerson\n", " srvprvUserAux\n", " organizationalPerson\n", " Person\n", " ndsLoginProperties\n", " Top\n", " srvprvEntityAux\n"]}
{ "index": { "_index": "volvo", "_type": "user" }}
{"dn": " cn=s1,o=VCC\n", "changetype": " add\n", "mail": " com\n", "surname": " sa\n", "givenname": " su\n", "cn": " s\n", "objectclass": [" inetOrgPerson\n", " srvprvUserAux\n", " organizationalPerson\n", " Person\n", " ndsLoginProperties\n", " Top\n", " srvprvEntityAux\n"]}
当我尝试将此批量索引到我的弹性搜索时,我收到以下错误,
{"error":{"root_cause":[{"type":"json_parse_exception","reason":"Unexpected character ('�' (code 65533 / 0xfffd)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@4914595e; line: 2, column: 2]"}],"type":"json_parse_exception","reason":"Unexpected character ('�' (code 65533 / 0xfffd)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@4914595e; line: 2, column: 2]"},"status":500}
你能弄清楚我的json有什么问题吗?
解决方案
我在批量索引时收到了同样的错误,并通过更改文件编码解决了这个问题。使用 Notepad++ 我将文件编码从 UTF-8-BOM 更改为 UTF-8,并且能够完成批量索引操作。
推荐阅读
- node.js - 如何使用 nodejs 在 dynamodb 中创建唯一的密钥?
- python - 从 nifti 格式的 MRI 图像中如何去除头骨
- docker - 不同服务器上的 docker 容器之间的通信
- themes - 由于尝试保存我的 tumblr 主题后不断弹出非 https url 消息,自定义 Tumblr 主题无法保存?
- concurrency - 为什么 I/O 多路复用是并发编程的一种形式
- r - 仅对 geom_bar 中的选定条使用不同的颜色
- javascript - NodeJS Promise Chaining:重用“then”并合并两个 Promise
- android - RCDevice 初始化时间过长
- android - 如何指定android自定义颜色资源:日/夜/高对比度
- c# - 使用 Unity 注册不存在的 MVC 类型(尚)