0

I've an elastic search cluster with "elasticsearch-head" plugin installed properly.

I want to use the _bulk API to insert several values at once but the specific format of _bulk request body seems to be causing troubles to the plugin.

I use the "Any query" panel to specify my request with the following setup:
query: /_bulk
body:

{ "create" : { "_index" : "eco", "_type" : "usage" } }
{ "index": 1, name" : "my_value" }

I get the following when validating the json and the request won't be executed:

JSON.parse: unexpected non-whitespace character after JSON data at line 2 column 1 of the JSON data

Does anyone knows if elasticsearch-head plugin can handle the _bulk API ? Or is there something wrong with my request ?

jeromes
  • 497
  • 5
  • 17

3 Answers3

1

elasticsearch-head plugin does not support _bulk, will cause JSON error... hope the author can support it as soon as possible, you can submit an issue to this below website. https://github.com/TravisTX/elasticsearch-head-chrome/issues

ohjo
  • 47
  • 4
0

You are missing the quotes before name.

{ "index": 1, "name" : "my_value" }

molerat
  • 946
  • 4
  • 15
  • 43
  • But it's not the same error message anymore, is it? – molerat Feb 08 '15 at 15:22
  • Either way, you should look at http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-bulk.html and see how to index documents. Both, create and indey, expect two lines: one with the meta data like indey, type and id and the second one with the values that the doc should have – molerat Feb 08 '15 at 16:10
0

Now 2021 Sep. 27, ES 7.15.0 .

I tried to use the "head" plugin send _bulk , it failed too.

but I found that using Postman or Curl , both are ok.

[PUT] http://localhost:9200/customer/external/_bulk

// Postman > Body > raw > JSON
{"index":{"_id":"1"}}
{"name":"a"}
{"index":{"_id":"2"}}
{"name":"b"}

Notice

  • Keep every json statement stay at each one line, do not expand them.
  • You need a blank line at the bottom.

With curl, you need save statements in a file, then @it:

$ curl -XPUT 'http://localhost:9200/customer/external/_bulk' -H "Content-Type:application/json" --data-binary @esSQL.json
Miozus
  • 1
  • 1