当我尝试在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"}
}
在cerebro插件中显示如下错误:
{
"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
}
答案 0 :(得分:0)
如果你的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
还要确保正确缩进。根据{{3}},您应该在json
的末尾添加新的换行符。您也可以查看此doc。希望能帮助到你!