简体   繁体   English

无法批量索引到elasticsearch

[英]Unable to bulk index to elasticsearch

I have json file as shown here,我有 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"]}

when i try to bulk index this to my elasticsearch, i get the following error,当我尝试将其批量索引到我的 elasticsearch 时,出现以下错误,

{"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}

Can you figure out whats the issue with my json.你能弄清楚我的json有什么问题吗?

I received the same error while bulk indexing and resolved the issue by changing the file encoding.我在批量索引时收到了同样的错误,并通过更改文件编码解决了这个问题。 Using Notepad++ I changed the file encoding from UTF-8-BOM to UTF-8 and was able to complete bulk index operation.使用 Notepad++,我将文件编码从 UTF-8-BOM 更改为 UTF-8,并且能够完成批量索引操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM