这是我的要求:
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}
{ "error": "IllegalArgumentException[Malformed action/metadata line
[3], expected START_OBJECT or END_OBJECT but found
[VALUE_STRING]]“,“状态”:500}
基本上,每个文档都是{“ firstname”:,“ lastname”:_}我不想将它们包装到父字段中。我从根本上缺少什么?
您只是缺少第二和第三个文档的操作行,请尝试如下操作:
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"}