1

I have the following JSON file

I have used awk to get rid of empty spaces, trailing, next line

awk -v ORS= -v OFS= '{$1=$1}1' data.json

I have added a create request at the top of my data.json followed by \n and the rest of my data.

{"create": {"_index":"socteam", "_type":"products"}} 

When I issue bulk submit request, I get the following error

CURL -XPUT http://localhost:9200/_bulk

{
  "took": 1,
  "errors": true,
  "items": [
    {
      "create": {
        "_index": "socteam",
        "_type": "products",
        "_id": "AVQuGPff-1Y7OIPIJaLX",
        "status": 400,
        "error": {
          "type": "mapper_parsing_exception",
          "reason": "failed to parse",
          "caused_by": {
            "type": "not_x_content_exception",
            "reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
          }
        }
      }
    }
  ]

Any idea on what this error mean? I haven't created any mapping, I'm using vanilla elasticsearch

2
  • I have a single JSON file, dose that mean I have to break it down? Commented Apr 19, 2016 at 11:35
  • 1
    You need to use POST for the _bulk call. Can you show the full curl command you're using? You're not showing your -d or --data-binary argument. Commented Apr 19, 2016 at 11:35

1 Answer 1

1

Accordingly to this doc, you have to specify index and type in URL:

curl -XPUT 'localhost:9200/socteam/products/_bulk?pretty' --data-binary "@data.json"

It works for PUT and POST methods.
And your data.json file should have structure like:

{"index":{"_id":"1"}}
{"name": "John Doe" }
{"index":{"_id":"2"}}
{"name": "Jane Doe" }

Maybe there present another method to import data, but i know just this... Hope it'll help...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.