4

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

Here is a payload Sample

cat data.json | awk -v ORS= -v OFS= '{$1=$1}1' | awk -v idx=test -v type=data 'BEGIN{print "{\"create\": {\"_index\":\"" idx "\", \"_type\":\"" type"\"}}"}; {print}; END {printf "\n"}' >> $file
        exit 0
        fi
    fi

Then I used httpie to submit the file to es

user1007727
  • 421
  • 5
  • 20
  • Can you post a sample of the data? Just two lines from the bulk API body would be fine (one index line and one data line) – Mark Henderson Oct 25 '16 at 15:15
  • I have attached sample JSON file to the question, it has sample data, is that what you are looking for? – user1007727 Oct 25 '16 at 15:16
  • I'm not seeing any samples in the question. I'm seeing `CURL -XPUT http://localhost:9200/_bulk`, which has no data (just the response), and I see your index line, and I see an `awk` command, but no complete request. i.e. what is your actual document you are trying to index? – Mark Henderson Oct 25 '16 at 15:17
  • http://pastebin.com/raw/r2pdcaW8 – user1007727 Oct 25 '16 at 15:18
  • That's not quite what I'm talking about. I mean your actual payload to the bulk API. You should have two lines for every document - the index line and the document line. Do you have the _actual payload_ you are sending? – Mark Henderson Oct 25 '16 at 15:21

0 Answers0