0

当我尝试在 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
}
4

1 回答 1

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

还要确保你有正确的缩进。根据文档,您应该在json. 你也可以看看这个SO。希望能帮助到你!

于 2017-01-04T10:51:21.233 回答