The first line is missing _ in the _type parameter, you need to use real new lines instead of \n characters and as it is outlined in on this documentation page
If you’re providing text file input to curl, you must use the --data-binary flag instead of plain -d. The latter doesn’t preserve newlines.
You might also find is easier to store bulk requests in a separate file, or use Kibana console to work with elasticsearch.
You are correct. Thank you for pointing that out. I had missed _ for type in the first line. Corrected the command however, still getting the same error -
curl -X POST --data-binary "{"index":{"_index":"products","_type":"shoes","_id":"3"}}{"name":"Puma","size":"9","color":"black"},{"index":{"_index":"products","_type":"shoes","_id":"4"}}{"name":"New Balance","size":"8","color":"black"}" -H "Content-type: application/json" -X POST "http://localhost:9200/_bulk?pretty"
You are correct. I am having a trouble understanding how to introduce a newline character when I type this command from command prompt of the Windows machine -
curl -X POST --data-binary "{"index":{"_index":"products","_type":"shoes","_id":"3"}},{"name":"Puma","size":"9","color":"black"}, (<---- I need a newline character here)
{"index":{"_index":"products","_type":"shoes","_id":"4"}},(<----- I need a newline character here)
{"name":"New Balance","size":"8","color":"black"}" -H "Content-type: application/x-ndjson" -X POST "http://localhost:9200/_bulk?pretty"
I tried even using "x-ndjson" as specified in the document but it did not work. Kindly help how do I do it?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.