2021年1月15日星期五

What am I doing wrong that is causing a

I can't figure out why I can't bulk load Elasticsearch with JSON... and it is killing me. I've done this before but this time I am totally stumped.

I have processed a set of JSON documents into Elastic Bulk Load Format and am trying to bulk load the index I just created (verified created, can be queried and is empty).

{"create": {"_id": "ef68e997-c616-4b0b-b08e-dfc09f8cb08f"}}  {"id": "ef68e997-c616-4b0b-b08e-dfc09f8cb08f", "title": "My document"}    ... repeats for all records  

The command I run uses a list of paths to the JSON bulk files and a loop to curl/POST them to Elastic using credentials:

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  

I've done all this before and it should work but... it doesn't. I get this error instead:

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  

This is maddening. Please help!

This example is also in a gist here

https://stackoverflow.com/questions/65745519/what-am-i-doing-wrong-that-is-causing-a January 16, 2021 at 09:05AM

没有评论:

发表评论