Problem using bulk api with -d flag

Hi,

if someone could indicate what is wrong in the following request, that
would be nice.

$ curl -XPOST localhost:9200/_bulk -d '{ "delete" : { "_index" : "test",
"_type" : "type1", "_id" : "5"}}'

The output of the above request is:

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

When passing the request input into a file it works fine, as shown below ...

$ curl -XPOST localhost:9200/_bulk --data-binary @delete_req; echo
{"took":0,"items":[{"delete":{"_index":"test","_type":"type1","_id":"5","_version":3,"ok":true}}]}

where the file delete_req contains the same input that is used with the -d
flag approach.

$ cat delete_req
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "5"}}

So, I guess I am overlooking a detail, and I would be grateful if someone
could point out the proper way to use the -d flag approach.

Thanks,
Sylvain

--

Hi Sylvain.

Have a look at http://www.elasticsearch.org/guide/reference/api/bulk.html

NOTE: the final line of data must end with a newline character \n.

If you’re providing text file input to curl, you must use the --data-binary
flag instead of plain -d. The latter doesn’t preserve newlines.

Could it be your concern?

David.

Le 4 décembre 2012 à 12:06, sylvain sylvain.bellemare@ezeep.com a écrit :

Hi,

if someone could indicate what is wrong in the following request, that would
be nice.

$ curl -XPOST localhost:9200/_bulk -d '{ "delete" : { "_index" : "test",
"_type" : "type1", "_id" : "5"}}'

The output of the above request is:

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

When passing the request input into a file it works fine, as shown below ...

$ curl -XPOST localhost:9200/_bulk --data-binary @delete_req; echo

{"took":0,"items":[{"delete":{"_index":"test","_type":"type1","_id":"5","_version":3,"ok":true}}]}

where the file delete_req contains the same input that is used with the -d
flag approach.

$ cat delete_req
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "5"}}

So, I guess I am overlooking a detail, and I would be grateful if someone
could point out the proper way to use the -d flag approach.

Thanks,
Sylvain

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

Thanks David for replying.

I tried with the end of line character as well, but it still does not work.

$ curl -XPOST localhost:9200/_bulk -d '{ "delete" : { "_index" : "test",
"_type" : "type1", "_id" : "5"}}\n'
{"error":"ActionRequestValidationException[Validation Failed: 1: no
requests added;]","status":500}

I am actually (trying) to follow the documentation
(http://www.elasticsearch.org/guide/reference/api/bulk.html), and using a
text file as input does work fine (with the --data-binary flag). What I
wish to know is how to make the request with the -d flag, without a text
file, by just passing the input as a string ...

On Tuesday, 4 December 2012 12:12:42 UTC+1, David Pilato wrote:

Hi Sylvain.

Have a look at http://www.elasticsearch.org/guide/reference/api/bulk.html

NOTE: the final line of data must end with a newline character \n.
If you’re providing text file input to curl, you must use the
--data-binary flag instead of plain -d. The latter doesn’t preserve
newlines.

Could it be your concern?

David.

Le 4 décembre 2012 à 12:06, sylvain <sylvain....@ezeep.com <javascript:>>
a écrit :

Hi,

if someone could indicate what is wrong in the following request, that
would be nice.

$ curl -XPOST localhost:9200/_bulk -d '{ "delete" : { "_index" :
"test", "_type" : "type1", "_id" : "5"}}'

The output of the above request is:

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

When passing the request input into a file it works fine, as shown below
...

$ curl -XPOST localhost:9200/_bulk --data-binary @delete_req; echo
{"took":0,"items":[{"delete":{"_index":"test","_type":"type1","_id":"5","_version":3,"ok":true}}]}

where the file delete_req contains the same input that is used with the
-d flag approach.

$ cat delete_req
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "5"}}

So, I guess I am overlooking a detail, and I would be grateful if someone
could point out the proper way to use the -d flag approach.

Thanks,
Sylvain

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

The following works ...

$ curl -XPOST localhost:9200/_bulk -d '{"delete": {"_index": "test",
"_type": "type1", "_id": "1"}

}'

On Tuesday, 4 December 2012 13:09:11 UTC+1, sylvain wrote:

Thanks David for replying.

I tried with the end of line character as well, but it still does not work.

$ curl -XPOST localhost:9200/_bulk -d '{ "delete" : { "_index" : "test",
"_type" : "type1", "_id" : "5"}}\n'
{"error":"ActionRequestValidationException[Validation Failed: 1: no
requests added;]","status":500}

I am actually (trying) to follow the documentation (
http://www.elasticsearch.org/guide/reference/api/bulk.html), and using a
text file as input does work fine (with the --data-binary flag). What I
wish to know is how to make the request with the -d flag, without a text
file, by just passing the input as a string ...

On Tuesday, 4 December 2012 12:12:42 UTC+1, David Pilato wrote:

Hi Sylvain.

Have a look at
http://www.elasticsearch.org/guide/reference/api/bulk.html

NOTE: the final line of data must end with a newline character \n.
If you’re providing text file input to curl, you must use the
--data-binary flag instead of plain -d. The latter doesn’t preserve
newlines.

Could it be your concern?

David.

Le 4 décembre 2012 à 12:06, sylvain sylvain....@ezeep.com a écrit :

Hi,

if someone could indicate what is wrong in the following request, that
would be nice.

$ curl -XPOST localhost:9200/_bulk -d '{ "delete" : { "_index" :
"test", "_type" : "type1", "_id" : "5"}}'

The output of the above request is:

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

When passing the request input into a file it works fine, as shown below
...

$ curl -XPOST localhost:9200/_bulk --data-binary @delete_req; echo
{"took":0,"items":[{"delete":{"_index":"test","_type":"type1","_id":"5","_version":3,"ok":true}}]}

where the file delete_req contains the same input that is used with the
-d flag approach.

$ cat delete_req
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "5"}}

So, I guess I am overlooking a detail, and I would be grateful if
someone could point out the proper way to use the -d flag approach.

Thanks,
Sylvain

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

But why do you use bulk for only one Delete action?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 déc. 2012 à 19:21, sylvain sylvain.bellemare@ezeep.com a écrit :

The following works ...

$ curl -XPOST localhost:9200/_bulk -d '{"delete": {"_index": "test", "_type": "type1", "_id": "1"}

}'

On Tuesday, 4 December 2012 13:09:11 UTC+1, sylvain wrote:
Thanks David for replying.

I tried with the end of line character as well, but it still does not work.

$ curl -XPOST localhost:9200/_bulk -d '{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "5"}}\n'
{"error":"ActionRequestValidationException[Validation Failed: 1: no requests added;]","status":500}

I am actually (trying) to follow the documentation (http://www.elasticsearch.org/guide/reference/api/bulk.html), and using a text file as input does work fine (with the --data-binary flag). What I wish to know is how to make the request with the -d flag, without a text file, by just passing the input as a string ...

On Tuesday, 4 December 2012 12:12:42 UTC+1, David Pilato wrote:
Hi Sylvain.

Have a look at http://www.elasticsearch.org/guide/reference/api/bulk.html

NOTE: the final line of data must end with a newline character \n.

If you’re providing text file input to curl, you must use the --data-binary flag instead of plain -d. The latter doesn’t preserve newlines.

Could it be your concern?

David.

Le 4 décembre 2012 à 12:06, sylvain sylvain....@ezeep.com a écrit :

Hi,

if someone could indicate what is wrong in the following request, that would be nice.

$ curl -XPOST localhost:9200/_bulk -d '{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "5"}}'

The output of the above request is:

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

When passing the request input into a file it works fine, as shown below ...

$ curl -XPOST localhost:9200/_bulk --data-binary @delete_req; echo
{"took":0,"items":[{"delete":{"_index":"test","_type":"type1","_id":"5","_version":3,"ok":true}}]}

where the file delete_req contains the same input that is used with the -d flag approach.

$ cat delete_req
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "5"}}

So, I guess I am overlooking a detail, and I would be grateful if someone could point out the proper way to use the -d flag approach.

Thanks,
Sylvain

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--