# Bulk query not working correctly

**URL:** <https://discuss.elastic.co/t/bulk-query-not-working-correctly/100044>\
**Category:** Elasticsearch\
**Created:** [September 11, 2017, 12:12pm UTC](https://discuss.elastic.co/t/bulk-query-not-working-correctly/100044 "2017-09-11T12:12:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjh](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@tjh](https://discuss.elastic.co/u/tjh)\
**Post date:** [September 11, 2017, 12:12pm UTC](https://discuss.elastic.co/t/bulk-query-not-working-correctly/100044/1 "2017-09-11T12:12:39Z")

</div>

Long parameter id strings lead to errors:

POST \_bulk  
{"create": {"\_type": "classified\_patentsubset", "\_parent": "32273201735", "\_index": "patclassifier", "\_id": "368\_1h"}}  
{"doc": {"date\_provided": "11.09.2017", "owner": "Eva van der Bey", "class": 0}}  
{"create": {"\_type": "classified\_patentsubset", "\_parent": "32216201735", "\_index": "patclassifier", "\_id": "368\_1h"}}  
{"doc": {"date\_provided": "11.09.2017", "owner": "Eva van der Bey", "class": 0}}

Leads to the following output:  
{  
"took": 41,  
"errors": true,  
"items": [  
{  
"create": {  
"\_index": "patclassifier",  
"\_type": "classified\_patentsubset",  
"\_id": "368\_1h",  
"\_version": 1,  
"result": "created",  
"\_shards": {  
"total": 2,  
"successful": 1,  
"failed": 0  
},  
"created": true,  
"status": 201  
}  
},  
{  
"create": {  
"\_index": "patclassifier",  
"\_type": "classified\_patentsubset",  
"\_id": "368\_1h",  
"status": 409,  
"error": {  
"type": "version\_conflict\_engine\_exception",  
"reason": "[classified\_patentsubset][368\_1h]: version conflict, document already exists (current version [1])",  
"index\_uuid": "Uljra9TmRm-qdwwg6zqa0Q",  
"shard": "0",  
"index": "patclassifier"  
}  
}  
}  
]  
}

While shortening the parent ids, works without problems:

POST \_bulk  
{"create": {"\_type": "classified\_patentsubset", "\_parent": "32273", "\_index": "patclassifier", "\_id": "368\_1j"}}  
{"doc": {"date\_provided": "11.09.2017", "owner": "Eva van der Bey", "class": 0}}  
{"create": {"\_type": "classified\_patentsubset", "\_parent": "32216", "\_index": "patclassifier", "\_id": "368\_1j"}}  
{"doc": {"date\_provided": "11.09.2017", "owner": "Eva van der Bey", "class": 0}}

Output is:

{  
"took": 5,  
"errors": false,  
"items": [  
{  
"create": {  
"\_index": "patclassifier",  
"\_type": "classified\_patentsubset",  
"\_id": "368\_1j",  
"\_version": 1,  
"result": "created",  
"\_shards": {  
"total": 2,  
"successful": 1,  
"failed": 0  
},  
"created": true,  
"status": 201  
}  
},  
{  
"create": {  
"\_index": "patclassifier",  
"\_type": "classified\_patentsubset",  
"\_id": "368\_1j",  
"\_version": 1,  
"result": "created",  
"\_shards": {  
"total": 2,  
"successful": 1,  
"failed": 0  
},  
"created": true,  
"status": 201  
}  
}  
]  
}

---

<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:** [September 11, 2017, 12:51pm UTC](https://discuss.elastic.co/t/bulk-query-not-working-correctly/100044/2 "2017-09-11T12:51:40Z")

</div>

The issue is that you have specified the bulk operation as `create`, which will fail if the document already exists. As you are routing on the parent document id, it looks like the first example resulted in both parent ids resulting in the same shard, which caused a conflict. In the second example this was likely not the case.

Apart from this it looks like you are trying to use parent-child mapping with more than one parent, which is not supported.

---

<div class="post-metadata">

**Author:** ![tjh](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@tjh](https://discuss.elastic.co/u/tjh)\
**Post date:** [September 12, 2017, 7:32am UTC](https://discuss.elastic.co/t/bulk-query-not-working-correctly/100044/3 "2017-09-12T07:32:46Z")

</div>

Thanks,

I was not aware that a child can not have many parents.

---

<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:** [October 10, 2017, 7:33am UTC](https://discuss.elastic.co/t/bulk-query-not-working-correctly/100044/4 "2017-10-10T07:33:00Z")

</div>

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