2

I'm performing a small benchmark on an Elastic Search cluster. My benchmark script is written in bash and uses curl.

I'm writing the data to a file that I'm posting to the REST API:

curl -XPOST 'localhost:9200/benchmark/external/_bulk?pretty' \
     --data @$DATAFILE

My $DATAFILE is very simple, and has all newlines in place:

{"index":{"_id": "1"}}
{"data":"xxxxxxxxxx"}
{"index":{"_id": "2"}}
{"data":"xxxxxxxxxx"}
{"index":{"_id": "3"}}
{"data":"xxxxxxxxxx"}
...

But when I try to do my post I keep receiving the following error:

{
  "error" : "ActionRequestValidationException[Validation Failed: 1: no requests added;]",
  "status" : 400
}

I understand that my input is not validated, but why?

André Laszlo
  • 15,169
  • 3
  • 63
  • 81

1 Answers1

2

curl removed the newlines before the data was sent!

The --data parameter should be replaced with --data-binary:

curl -XPOST 'localhost:9200/benchmark/external/_bulk?pretty' \
     --data-binary @$DATAFILE
André Laszlo
  • 15,169
  • 3
  • 63
  • 81