BULK API : Malformed action/metadata line [3], expected START_OBJECT but found [VALUE_STRING] BULK API : Malformed action/metadata line [3], expected START_OBJECT but found [VALUE_STRING] elasticsearch elasticsearch

BULK API : Malformed action/metadata line [3], expected START_OBJECT but found [VALUE_STRING]


Your resource objects have to be specified on a single line like this

post /test322/type/_bulk{ "index": {} }{ "name": "Test1", "data": "This is my test data" }{ "index": {} }{ "name": "Test2", "data": "This is my test data2" }

Which seems really stupid and unintuitive I know since resources don't have to be on a single line when you create them using PUT or POST for non-bulk operations.


The following lines' format worked for me very well: Action, metadata, resource

Note: Action should be CREATE to add a resource to the dataset and resource should be written inline, NOT new line.

  POST http://localhost:9200/access_log_index/access_log/_bulk  { "create" : { "_index" : "test", "_type" : "_doc", "_id" : "11" } }  {  "id":11, "tenant_id":682 , ... }


You need to follow bulk format to successfully execute this.it expects the following JSON structure:

action_and_meta_data\noptional_source\naction_and_meta_data\noptional_source\n....action_and_meta_data\noptional_source\n

For further reference, see this link https://www.elastic.co/guide/en/elasticsearch/reference/6.2/docs-bulk.html