输入意外结束:数组elasticsearch需要close标记

4uqofj5v  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(1)|浏览(333)

我正在创建批量请求的ElasticSearch,但得到的错误,其中指定的标题可以任何人检查我的json可能这是不对的

{ "index" :{ "_index" : "type", "_type" : "type", "_id" : "1" }}
{"type": "Variable", "processDefinitionKey":"Variable1", "products":[
{ "index" :{ "_index" : "new_type", "_type" : "new_type", "_id" : "1" }}
{ "code": "20", "type": "Variable", "name": "Integer"}]}
xxslljrj

xxslljrj1#

实际上,问题是文档似乎被分割在第2行和第4行之间,而且这两行都不完整

{ "index" :{ "_index" : "type", "_type" : "type", "_id" : "1" }}
{"type": "Variable", "processDefinitionKey":"Variable1", "products":[
{ "index" :{ "_index" : "new_type", "_type" : "new_type", "_id" : "1" }}
{ "code": "20", "type": "Variable", "name": "Integer"}]}

你的文件是这样的

{"type": "Variable", "processDefinitionKey":"Variable1", "products":[

再加上这个

{ "code": "20", "type": "Variable", "name": "Integer"}]}

但它被分成两行 index 中间的命令。。。那不行。
它应该是这样的:

{ "index" :{ "_index" : "type", "_type" : "type", "_id" : "1" }}
{"type": "Variable", "processDefinitionKey":"Variable1", "products":[{ "code": "20", "type": "Variable", "name": "Integer"}]}
{ "index" :{ "_index" : "new_type", "_type" : "new_type", "_id" : "1" }}
{"type": "Variable", "processDefinitionKey":"Variable1", "products":[{ "code": "20", "type": "Variable", "name": "Integer"}]}

您需要确保:
json文档位于一行(不是多行)
每个json文档都有相应的命令行
最后一行以换行符结尾(由于so格式,上面不可见)

相关问题