Skip to content

Instantly share code, notes, and snippets.

@rjurney
Last active January 16, 2021 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjurney/7aa024b66f7391403747cd84a8bec071 to your computer and use it in GitHub Desktop.
Save rjurney/7aa024b66f7391403747cd84a8bec071 to your computer and use it in GitHub Desktop.
What am I doing wrong in this Elastic bulk load command? I can't figure it out!
while IFS= read -r "path" < "${DOC_LIST_PATH}"
do
echo "Submitting Elastic formatted docs at ${path} to Elastic index 'docs' ..."
curl \
-X POST \
-H "Content-Type: application/x-ndjson" \
"https://${ES_USER}:${ES_PASSWD}@${ES_HOSTNAME}:${ES_PORT}/docs/_bulk" \
--data-binary "@${path}"
done
Submitting Elastic formatted docs at data/docs_elastic.json/part-00000.json to Elastic index 'docs' ...
Warning: Couldn't read data from file
Warning: "data/docs_elastic.json/part-00000.json",
Warning: this makes an empty POST.
{"error":{"root_cause":[{"type":"parse_exception","reason":"request body is required"}],"type":"parse_exception","reason":"request body is required"},"status":400}
... repeats for all files
{"create": {"_id": "ef68e997-c616-4b0b-b08e-dfc09f8cb08f"}}
{"id": "ef68e997-c616-4b0b-b08e-dfc09f8cb08f", "title": "@Lastmohican - Lastmohican - Yep", "description": "Yep", "thread": [{"username": "@Lastmohican", "name": "Devon Kinsey", "timestamp": "2021-01-03T00:00:00+00:00", "body": "Yep"}]}
... repeats for all records
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment