当我尝试在 cerebro 插件中发布以下代码时
POST /_bulk
{
"index" : { "_index" : "test", "_type" : "type1", "_id" : "1" },
"field1" : "value1" ,
"delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" },
"create" : { "_index" : "test", "_type" : "type1", "_id" : "3" },
"field2" : "value3" ,
"update" : {"_id" : "1", "_type" : "type1", "_index" : "test"},
"doc" : {"field3" : "value2"}
}
它在大脑插件中显示如下错误:
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: no requests added;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: no requests added;"
},
"status": 400
}
如果你的json
身体最终有一个新行n
字符,它可能看起来像这样:
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" }}
{"field1" : "value1"}
{"delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" }}
{"create" : { "_index" : "test", "_type" : "type1", "_id" : "3" }}
{"field2" : "value3"}
{"update" : {"_id" : "1", "_type" : "type1", "_index" : "test"}}
{"doc" : {"field3" : "value2"}}n
还要确保缩进正确。根据文档,您应该在json
末尾使用换行符。你也可以看看这个SO。希望对您有所帮助!