diepm / vim-rest-console

A REST console for Vim.
658 stars 54 forks source link

Inline bulk in ES? #41

Closed rawaludin closed 7 years ago

rawaludin commented 7 years ago

I know I could attach a json to do bulk ES query. But, is it possible to do it inline? I've tried this but keep getting error

http://localhost:9200
post /_bulk
{ "delete": { "_index": "website", "_type": "blog", "_id": "123" }}
{ "create": { "_index": "website", "_type": "blog", "_id": "123" }}
{ "title":    "my first blog post" }
{ "index":  { "_index": "website", "_type": "blog" }}
{ "title":    "my second blog post" }
{ "update": { "_index": "website", "_type": "blog", "_id": "123", "_retry_on_conflict" : 3} }
{ "doc" : {"title" : "my updated blog post"} }
HTTP/1.1 400 Bad Request
content-type: application/json; charset=UTF-8
content-length: 235

{
    "error": {
        "reason": "Validation Failed: 1: no requests added;",
        "root_cause": [
            {
                "reason": "Validation Failed: 1: no requests added;",
                "type": "action_request_validation_exception"
            }
        ],
        "type": "action_request_validation_exception"
    },
    "status": 400
}
diepm commented 7 years ago

As I remember, initially VRC supported inline bulk but it was a hacky way (due to the requirement on the newline character). I'll see if I can bring it back (I'm in the process of setting up my machine from scratch).

In the meantime, you can enable the debug mode and check the request output to see what's going wrong. Your feedback will be helpful. Thanks!

diepm commented 7 years ago

I've added back the support for inline bulk request. It's currently in the dev branch. You can check it out and see if it works.

One thing to do is to set let g:vrc_elasticsearch_support = 1 so that VRC knows how to parse the request body.

diepm commented 7 years ago

Should work now with v3.0.0.