一尘不染

通过其余端点的Elasticsearch批量索引API

elasticsearch

这是我的要求:

POST /_bulk
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{"firstname":"first_name1","lastname":"last_name1"},
{"firstname":"first_name2","lastname":"last_name2"},
{"firstname":"first_name3","lastname":"last_name3"}}

这是错误:

{    "error": "IllegalArgumentException[Malformed action/metadata line

[3], expected START_OBJECT or END_OBJECT but found

[VALUE_STRING]]“,“状态”:500}

基本上,每个文档都是{“ firstname”:,“ lastname”:_}我不想将它们包装到父字段中。我从根本上缺少什么?


阅读 242

收藏
2020-06-22

共1个答案

一尘不染

您只是缺少第二和第三个文档的操作行,请尝试如下操作:

POST /_bulk
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{"firstname":"first_name1","lastname":"last_name1"}
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{"firstname":"first_name2","lastname":"last_name2"}
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
{"firstname":"first_name3","lastname":"last_name3"}
2020-06-22