通过命令行将ndjson导入elasticsearch 7.2
我有一个ndjson文件data.json,类似于: 我想将其插入elasticSearch 7.2,并使用curl 但回调错误是:通过命令行将ndjson导入elasticsearch 7.2,json,
elasticsearch,Json,
elasticsearch,我有一个ndjson文件data.json,类似于: 我想将其插入elasticSearch 7.2,并使用curl 但回调错误是: { "error":{ "root_cause":[{ "type":"illegal_argument_exception", "reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [VALUE_STRING]" }], "type"
{
"error":{
"root_cause":[{
"type":"illegal_argument_exception",
"reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [VALUE_STRING]"
}],
"type":"illegal_argument_exception",
"reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [VALUE_STRING]"
},
"status":400
}
我的操作系统是MacOS Mojave 10.14.5
如何解决此问题?每个文档的第一个操作/元数据行需要稍微不同。您的data.json文件应如下所示:
{"index": {"_index": "products"}}
{"title": "item1", "price": 1}
{"index": {"_index": "products"}}
{"title": "item2", "price": 2}
{"index": {"_index": "products"}}
{"title": "item3", "price": 3}
{"index": {"_index": "products"}}
{"title": "item4", "price": 4}
缺少price属性。但是price是整数属性yyes,但是属性名称本身需要包装,price->price应该可以做到这一点。
{
"error":{
"root_cause":[{
"type":"illegal_argument_exception",
"reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [VALUE_STRING]"
}],
"type":"illegal_argument_exception",
"reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [VALUE_STRING]"
},
"status":400
}
{"index": {"_index": "products"}}
{"title": "item1", "price": 1}
{"index": {"_index": "products"}}
{"title": "item2", "price": 2}
{"index": {"_index": "products"}}
{"title": "item3", "price": 3}
{"index": {"_index": "products"}}
{"title": "item4", "price": 4}