Yaswanth
(Yaswanth )
January 6, 2017, 6:41pm
1
Hi everyone,
when i am using bulk api in the kopf plugin i am getting an syntax error . I copied the code that is present in the elasticsearch 5.1 guide.My code is
POST _bulk
{
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{ "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"_id" : "1", "_type" : "type1", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }
}
Even i tried giving \n at the end of each line but nothing solved the problem. Can anyone help me in solving it ?
Thanks
Yaswanth
(Yaswanth )
January 7, 2017, 1:05pm
3
Even i tried different ways like:
1)Giving "\n" at every end of the line .
2)Giving "\n" at end of last line.
3)Even i tried removing flower brackets at top and bottom
But the error remains..
Remove the first and last line that only contain a curly brace. Each line need to be a JSON object followed by a newline.
Yaswanth
(Yaswanth )
January 7, 2017, 4:59pm
5
That means you want me to add newline(\n) at the end of each line..pls correct me if i am wrong
The correct format is described here , so the request body should look as follows:
{ "index" : { "index" : "test", "type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "index" : "test", "type" : "type1", "_id" : "2" } }
{ "create" : { "index" : "test", "type" : "type1", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"id" : "1", "type" : "type1", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }
I have however never used Kopf for bulk requests, so do not know it adds any formatting or validations behind the scenes.
Yaswanth
(Yaswanth )
January 7, 2017, 5:23pm
7
Thanks for your help but still it is showing syntax error..
Aha, you need to look at the example in the link I provided. It should look as follows:
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{ "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"_id" : "1", "_type" : "type1", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }
In your example some of the fields do not have the required starting underscore.
Yaswanth
(Yaswanth )
January 8, 2017, 8:54am
9
Thankyou .. Eventhough when i used the code in the link which you had given the kopf plugin is showing syntax error but when i tried executing it .It worked fine..
system
(system)
Closed
February 5, 2017, 8:54am
10
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.