# Bulk api syntax error in kopf plugin

**URL:** <https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810>\
**Category:** Elasticsearch\
**Created:** [January 6, 2017, 6:41pm UTC](https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810 "2017-01-06T18:41:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [January 6, 2017, 6:41pm UTC](https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810/1 "2017-01-06T18:41:32Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 7, 2017, 10:06am UTC](https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810/2 "2017-01-07T10:06:12Z")

</div>

What is the error?

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [January 7, 2017, 1:05pm UTC](https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810/3 "2017-01-07T13:05:52Z")

</div>

![](https://us1.discourse-cdn.com/elastic/original/2X/1/11b83554cac1562aa1bd713bcbf937ff6ca2b7b4.png)

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..

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 7, 2017, 4:42pm UTC](https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810/4 "2017-01-07T16:42:08Z")

</div>

Remove the first and last line that only contain a curly brace. Each line need to be a JSON object followed by a newline.

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [January 7, 2017, 4:59pm UTC](https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810/5 "2017-01-07T16:59:17Z")

</div>

That means you want me to add newline(\n) at the end of each line..pls correct me if i am wrong

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 7, 2017, 5:03pm UTC](https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810/6 "2017-01-07T17:03:10Z")

</div>

The correct format is described [here](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/docs-bulk.html), 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.

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [January 7, 2017, 5:23pm UTC](https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810/7 "2017-01-07T17:23:53Z")

</div>

Thanks for your help but still it is showing syntax error..

 ![](https://us1.discourse-cdn.com/elastic/original/2X/e/ea548f101749821f4e0a04c7529a9c3aff0d0190.png)

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 7, 2017, 9:36pm UTC](https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810/8 "2017-01-07T21:36:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [January 8, 2017, 8:54am UTC](https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810/9 "2017-01-08T08:54:25Z")

</div>

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..

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 5, 2017, 8:54am UTC](https://discuss.elastic.co/t/bulk-api-syntax-error-in-kopf-plugin/70810/10 "2017-02-05T08:54:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
