0

When i tried to post the below code in cerebro plugin

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"} 
}

It is showing error like this in cerebro plugin:

    {
  "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
}
Private
  • 1,661
  • 1
  • 20
  • 51
  • Cerebro doesn't support the bulk format right now, I've [filed an issue](https://github.com/lmenezes/cerebro/issues/130), we'll see what unfolds. – Val Apr 17 '17 at 07:14
  • You can try in kopf in this bulk api works.. – Private Apr 17 '17 at 07:50
  • Yes, it used to work in kopf, but that was a site plugin. cerebro is now a full-fledge scala app and has been completely rewritten, some features are still missing. – Val Apr 17 '17 at 08:03

1 Answers1

1

What if you have your json body ending up with a new line \n character, which could look something like this:

    { "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

Also make sure that you have your indentation properly. As per the doc, you should be having the new line character at the end of your json. You may have a look at this SO as well. Hope it helps!

Community
  • 1
  • 1
Kulasangar
  • 9,046
  • 5
  • 51
  • 82
  • I tried giving \n in at the end of doc but cerebro plugin is showing it as bad syntax. I indented the content nothing helped.. – Private Jan 04 '17 at 11:49