Elasticsearch: Bulk request throws error in Elasticsearch 6.1.1

前端 未结 16 2044
日久生厌
日久生厌 2020-12-16 11:35

I recently upgraded to Elasticsearch version 6.1.1 and now I can\'t bulk index documents from a JSON file. When I do it inline, it works fine. Here are the contents of the d

相关标签:
16条回答
  • 2020-12-16 12:05

    Add empty line at the end of the JSON file and save the file and then try to run the below command

    curl -XPOST localhost:9200/subscribers/ppl/_bulk?pretty --data-binary @customers_full.json -H 'Content-Type: application/json'
    

    I hope it works fine for you.

    0 讨论(0)
  • 2020-12-16 12:05

    you just need to open json file and then go to the end of the file ( Ctrl+end) and then please Enter to break a new line.

    0 讨论(0)
  • 2020-12-16 12:05

    This worked for me:

    curl -H "Content-Type: application/x-ndjson" -XPOST "localhost:9200/bank/_bulk?pretty&refresh" --data-binary "@C:\Program Files\Elastic\Elasticsearch\7.2.0\accounts.json"
    
    0 讨论(0)
  • 2020-12-16 12:06

    This worked in my local set-up.

    curl -H "Content-type:application/json" -XPOST "http://localhost:9200/customer/personal/_bulk?pretty" --data-binary @"generated.json"
    
    0 讨论(0)
  • 2020-12-16 12:07

    I had a similar issue when working with Elasticsearch 7.3.

    Here's how I solved it.

    1. Locate the .json file, say products.json file.
    2. Double click to open the .json file in your text editor.
    3. Scroll to the end of the .json file and then press the ENTER key on your keyboard.
    4. Close the .json file. This will create a new line at the end of .json file.
    5. Go back to your terminal and run the command below.

    N/B: For the command below, the .json file name is products.json which I am importing to http://localhost:9200/ecommerce/product

    curl -H "Content-type: application/json" -XPOST "http://localhost:9200/ecommerce/product/_bulk?pretty" --data-binary "@products.json"
    

    That's all.

    I hope this helps

    0 讨论(0)
  • 2020-12-16 12:07

    You need to use --data-binary instead of -d in your curl request. Please see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

    0 讨论(0)
提交回复
热议问题