Bulk request throws error in elasticsearch 6.1.1
up vote
7
down vote
favorite
I recently upgraded to elasticsearch version 6.1.1 and now I can't bulk index documents from a json file. Wehn I do it inline, it works fine. Here are the contents of the document:
{"index" : {}}
{"name": "Carlson Barnes", "age": 34}
{"index":{}}
{"name": "Sheppard Stein","age": 39}
{"index":{}}
{"name": "Nixon Singleton","age": 36}
{"index":{}}
{"name": "Sharron Sosa","age": 33}
{"index":{}}
{"name": "Kendra Cabrera","age": 24}
{"index":{}}
{"name": "Young Robinson","age": 20}
When I run this command,
curl -XPUT 'localhost:9200/subscribers/ppl/_bulk?pretty' -H 'Content-Type: application/json' -d @customers_full.json
I get this error:
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [n]"
}
],
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [n]"
},
"status" : 400
It works fine if I send the data inline and in elasticsearch 5.x. I tried adding newlines as well as the newline character to the end of the file. Doesn't seem to work.
json
add a comment |
up vote
7
down vote
favorite
I recently upgraded to elasticsearch version 6.1.1 and now I can't bulk index documents from a json file. Wehn I do it inline, it works fine. Here are the contents of the document:
{"index" : {}}
{"name": "Carlson Barnes", "age": 34}
{"index":{}}
{"name": "Sheppard Stein","age": 39}
{"index":{}}
{"name": "Nixon Singleton","age": 36}
{"index":{}}
{"name": "Sharron Sosa","age": 33}
{"index":{}}
{"name": "Kendra Cabrera","age": 24}
{"index":{}}
{"name": "Young Robinson","age": 20}
When I run this command,
curl -XPUT 'localhost:9200/subscribers/ppl/_bulk?pretty' -H 'Content-Type: application/json' -d @customers_full.json
I get this error:
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [n]"
}
],
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [n]"
},
"status" : 400
It works fine if I send the data inline and in elasticsearch 5.x. I tried adding newlines as well as the newline character to the end of the file. Doesn't seem to work.
json
Issue resolved?
– Sathishkumar Rakkiasamy
Mar 17 at 19:16
add a comment |
up vote
7
down vote
favorite
up vote
7
down vote
favorite
I recently upgraded to elasticsearch version 6.1.1 and now I can't bulk index documents from a json file. Wehn I do it inline, it works fine. Here are the contents of the document:
{"index" : {}}
{"name": "Carlson Barnes", "age": 34}
{"index":{}}
{"name": "Sheppard Stein","age": 39}
{"index":{}}
{"name": "Nixon Singleton","age": 36}
{"index":{}}
{"name": "Sharron Sosa","age": 33}
{"index":{}}
{"name": "Kendra Cabrera","age": 24}
{"index":{}}
{"name": "Young Robinson","age": 20}
When I run this command,
curl -XPUT 'localhost:9200/subscribers/ppl/_bulk?pretty' -H 'Content-Type: application/json' -d @customers_full.json
I get this error:
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [n]"
}
],
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [n]"
},
"status" : 400
It works fine if I send the data inline and in elasticsearch 5.x. I tried adding newlines as well as the newline character to the end of the file. Doesn't seem to work.
json
I recently upgraded to elasticsearch version 6.1.1 and now I can't bulk index documents from a json file. Wehn I do it inline, it works fine. Here are the contents of the document:
{"index" : {}}
{"name": "Carlson Barnes", "age": 34}
{"index":{}}
{"name": "Sheppard Stein","age": 39}
{"index":{}}
{"name": "Nixon Singleton","age": 36}
{"index":{}}
{"name": "Sharron Sosa","age": 33}
{"index":{}}
{"name": "Kendra Cabrera","age": 24}
{"index":{}}
{"name": "Young Robinson","age": 20}
When I run this command,
curl -XPUT 'localhost:9200/subscribers/ppl/_bulk?pretty' -H 'Content-Type: application/json' -d @customers_full.json
I get this error:
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [n]"
}
],
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [n]"
},
"status" : 400
It works fine if I send the data inline and in elasticsearch 5.x. I tried adding newlines as well as the newline character to the end of the file. Doesn't seem to work.
json
json
edited May 7 at 21:58
Mehdi LAMRANI
6,252115999
6,252115999
asked Feb 2 at 9:52
Judy T Raj
235218
235218
Issue resolved?
– Sathishkumar Rakkiasamy
Mar 17 at 19:16
add a comment |
Issue resolved?
– Sathishkumar Rakkiasamy
Mar 17 at 19:16
Issue resolved?
– Sathishkumar Rakkiasamy
Mar 17 at 19:16
Issue resolved?
– Sathishkumar Rakkiasamy
Mar 17 at 19:16
add a comment |
7 Answers
7
active
oldest
votes
up vote
13
down vote
accepted
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.
add a comment |
up vote
5
down vote
The error is pretty clear:
The bulk request must be terminated by a newline [n]
So you simply need to add a newline at the end of your customers_full.json file and you'll be ok.
I did that. I added a newline. I tried adding the newline character, still doesn't work.
– Judy T Raj
Feb 2 at 9:54
I tried the same thing against ES 6.1.3 and it worked perfectly
– Val
Feb 2 at 10:04
1
Instead of-dyou should try to use--data-binary
– Val
Feb 2 at 10:41
That didn't work either.
– Judy T Raj
Feb 2 at 12:30
Can you gist your JSON file?
– Val
Feb 2 at 12:39
|
show 4 more comments
up vote
3
down vote
As the document says: use the --data-binary flag instead of plain -d. The latter doesn’t preserve newlines and do not format the json.
I faced this problem because of JSON formatting.
add a comment |
up vote
2
down vote
I ran into the same issue and spent hours adding and removing newlines before somebody pointed out I mis-typed the file name... So note that curl will throw the same error if the file is not actually present, making this super-confusing.
add a comment |
up vote
1
down vote
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
add a comment |
up vote
0
down vote
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.
add a comment |
up vote
0
down vote
Press Enter end of the line inside json file and run the command again .
curl -H "Content-Type: application/x-ndjson" -XPOST 'localhost:9200/customers/personal/_bulk?pretty&refresh' --data-binary @"generated.json"
add a comment |
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
13
down vote
accepted
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.
add a comment |
up vote
13
down vote
accepted
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.
add a comment |
up vote
13
down vote
accepted
up vote
13
down vote
accepted
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.
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.
answered Mar 16 at 22:12
Sathishkumar Rakkiasamy
6241818
6241818
add a comment |
add a comment |
up vote
5
down vote
The error is pretty clear:
The bulk request must be terminated by a newline [n]
So you simply need to add a newline at the end of your customers_full.json file and you'll be ok.
I did that. I added a newline. I tried adding the newline character, still doesn't work.
– Judy T Raj
Feb 2 at 9:54
I tried the same thing against ES 6.1.3 and it worked perfectly
– Val
Feb 2 at 10:04
1
Instead of-dyou should try to use--data-binary
– Val
Feb 2 at 10:41
That didn't work either.
– Judy T Raj
Feb 2 at 12:30
Can you gist your JSON file?
– Val
Feb 2 at 12:39
|
show 4 more comments
up vote
5
down vote
The error is pretty clear:
The bulk request must be terminated by a newline [n]
So you simply need to add a newline at the end of your customers_full.json file and you'll be ok.
I did that. I added a newline. I tried adding the newline character, still doesn't work.
– Judy T Raj
Feb 2 at 9:54
I tried the same thing against ES 6.1.3 and it worked perfectly
– Val
Feb 2 at 10:04
1
Instead of-dyou should try to use--data-binary
– Val
Feb 2 at 10:41
That didn't work either.
– Judy T Raj
Feb 2 at 12:30
Can you gist your JSON file?
– Val
Feb 2 at 12:39
|
show 4 more comments
up vote
5
down vote
up vote
5
down vote
The error is pretty clear:
The bulk request must be terminated by a newline [n]
So you simply need to add a newline at the end of your customers_full.json file and you'll be ok.
The error is pretty clear:
The bulk request must be terminated by a newline [n]
So you simply need to add a newline at the end of your customers_full.json file and you'll be ok.
answered Feb 2 at 9:53
Val
99.9k6130167
99.9k6130167
I did that. I added a newline. I tried adding the newline character, still doesn't work.
– Judy T Raj
Feb 2 at 9:54
I tried the same thing against ES 6.1.3 and it worked perfectly
– Val
Feb 2 at 10:04
1
Instead of-dyou should try to use--data-binary
– Val
Feb 2 at 10:41
That didn't work either.
– Judy T Raj
Feb 2 at 12:30
Can you gist your JSON file?
– Val
Feb 2 at 12:39
|
show 4 more comments
I did that. I added a newline. I tried adding the newline character, still doesn't work.
– Judy T Raj
Feb 2 at 9:54
I tried the same thing against ES 6.1.3 and it worked perfectly
– Val
Feb 2 at 10:04
1
Instead of-dyou should try to use--data-binary
– Val
Feb 2 at 10:41
That didn't work either.
– Judy T Raj
Feb 2 at 12:30
Can you gist your JSON file?
– Val
Feb 2 at 12:39
I did that. I added a newline. I tried adding the newline character, still doesn't work.
– Judy T Raj
Feb 2 at 9:54
I did that. I added a newline. I tried adding the newline character, still doesn't work.
– Judy T Raj
Feb 2 at 9:54
I tried the same thing against ES 6.1.3 and it worked perfectly
– Val
Feb 2 at 10:04
I tried the same thing against ES 6.1.3 and it worked perfectly
– Val
Feb 2 at 10:04
1
1
Instead of
-d you should try to use --data-binary– Val
Feb 2 at 10:41
Instead of
-d you should try to use --data-binary– Val
Feb 2 at 10:41
That didn't work either.
– Judy T Raj
Feb 2 at 12:30
That didn't work either.
– Judy T Raj
Feb 2 at 12:30
Can you gist your JSON file?
– Val
Feb 2 at 12:39
Can you gist your JSON file?
– Val
Feb 2 at 12:39
|
show 4 more comments
up vote
3
down vote
As the document says: use the --data-binary flag instead of plain -d. The latter doesn’t preserve newlines and do not format the json.
I faced this problem because of JSON formatting.
add a comment |
up vote
3
down vote
As the document says: use the --data-binary flag instead of plain -d. The latter doesn’t preserve newlines and do not format the json.
I faced this problem because of JSON formatting.
add a comment |
up vote
3
down vote
up vote
3
down vote
As the document says: use the --data-binary flag instead of plain -d. The latter doesn’t preserve newlines and do not format the json.
I faced this problem because of JSON formatting.
As the document says: use the --data-binary flag instead of plain -d. The latter doesn’t preserve newlines and do not format the json.
I faced this problem because of JSON formatting.
answered Jun 1 at 20:28
Utsav
406
406
add a comment |
add a comment |
up vote
2
down vote
I ran into the same issue and spent hours adding and removing newlines before somebody pointed out I mis-typed the file name... So note that curl will throw the same error if the file is not actually present, making this super-confusing.
add a comment |
up vote
2
down vote
I ran into the same issue and spent hours adding and removing newlines before somebody pointed out I mis-typed the file name... So note that curl will throw the same error if the file is not actually present, making this super-confusing.
add a comment |
up vote
2
down vote
up vote
2
down vote
I ran into the same issue and spent hours adding and removing newlines before somebody pointed out I mis-typed the file name... So note that curl will throw the same error if the file is not actually present, making this super-confusing.
I ran into the same issue and spent hours adding and removing newlines before somebody pointed out I mis-typed the file name... So note that curl will throw the same error if the file is not actually present, making this super-confusing.
answered May 30 at 20:45
Raya Fratkina
211
211
add a comment |
add a comment |
up vote
1
down vote
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
add a comment |
up vote
1
down vote
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
add a comment |
up vote
1
down vote
up vote
1
down vote
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
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
answered Mar 16 at 20:54
Karim
111
111
add a comment |
add a comment |
up vote
0
down vote
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.
add a comment |
up vote
0
down vote
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.
add a comment |
up vote
0
down vote
up vote
0
down vote
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.
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.
answered Feb 7 at 7:47
user6589750
11
11
add a comment |
add a comment |
up vote
0
down vote
Press Enter end of the line inside json file and run the command again .
curl -H "Content-Type: application/x-ndjson" -XPOST 'localhost:9200/customers/personal/_bulk?pretty&refresh' --data-binary @"generated.json"
add a comment |
up vote
0
down vote
Press Enter end of the line inside json file and run the command again .
curl -H "Content-Type: application/x-ndjson" -XPOST 'localhost:9200/customers/personal/_bulk?pretty&refresh' --data-binary @"generated.json"
add a comment |
up vote
0
down vote
up vote
0
down vote
Press Enter end of the line inside json file and run the command again .
curl -H "Content-Type: application/x-ndjson" -XPOST 'localhost:9200/customers/personal/_bulk?pretty&refresh' --data-binary @"generated.json"
Press Enter end of the line inside json file and run the command again .
curl -H "Content-Type: application/x-ndjson" -XPOST 'localhost:9200/customers/personal/_bulk?pretty&refresh' --data-binary @"generated.json"
answered Oct 9 at 19:22
sourabh kumar verma
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48579980%2fbulk-request-throws-error-in-elasticsearch-6-1-1%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Issue resolved?
– Sathishkumar Rakkiasamy
Mar 17 at 19:16