Using Elasticsearch 5.5,getting the following error while posting this bulk request, unable to figure out what is wrong with the request.
\"type\": \"illegal
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\n
optional_source\n
action_and_meta_data\n
optional_source\n
....
action_and_meta_data\n
optional_source\n
For further reference, see this link https://www.elastic.co/guide/en/elasticsearch/reference/6.2/docs-bulk.html