Error while uploading bulk json to elasticsearch domain

I am trying to upload the below json file to the elasticsearch domain I have on aws and getting the below error:

Input json file:

{"index": {"_index": "ods-pcd-poc","_id": "1"}}{"Page": 0,"Path": "//Document/Figure","Text": ""}{"index": {"_index": "ods-pcd-poc","_id": "2"}}{"Page": 0,"Path": "//Document/P","Text": "GUIDELINES FOR PATIENTS 2022 Non-Small Cell Lung Cancer Metastatic "}{"index": {"_index": "ods-pcd-poc","_id": "3"}}{"Page": 0,"Path": "//Document/Figure[2]","Text": ""}{"index": {"_index": "ods-pcd-poc","_id": "4"}}{"Page": 0,"Path": "//Document/P[2]/Reference","Text": "(<http://www.nccn.org/patients>)Available online at NCCN.org/patients "}

Command:
curl -XPUT '/_bulk' --data-binary @example.json -H 'Content-Type: application/json'

Error:
{"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}

I have added new line char at the end of the file. What is the possible cause of this error?

You also need a newline between each JSON object.

{"index": {"_index": "ods-pcd-poc","_id": "1"}}
{"Page": 0,"Path": "//Document/Figure","Text": ""}
{"index": {"_index": "ods-pcd-poc","_id": "2"}}
{"Page": 0,"Path": "//Document/P","Text": "GUIDELINES FOR PATIENTS 2022 Non-Small Cell Lung Cancer Metastatic "}
...

thanks! it worked.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.