# Bulk indexing depending on a "delete by query"

**URL:** <https://discuss.elastic.co/t/bulk-indexing-depending-on-a-delete-by-query/109901>\
**Category:** Elasticsearch\
**Created:** [December 1, 2017, 9:34am UTC](https://discuss.elastic.co/t/bulk-indexing-depending-on-a-delete-by-query/109901 "2017-12-01T09:34:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonkallenberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/antonkallenberg/32/6259_2.png) [@antonkallenberg](https://discuss.elastic.co/u/antonkallenberg)\
**Post date:** [December 1, 2017, 9:34am UTC](https://discuss.elastic.co/t/bulk-indexing-depending-on-a-delete-by-query/109901/1 "2017-12-01T09:34:53Z")

</div>

Hi!

Is it safe to have an bulk indexing operation depending on a "delete by query"?

Lets say that I have 10 car document within my index, 5 of them of brand BMW, I perform a bulk indexing of 10 more BMW cars but before I perform the bulk indexing I delete all cars where brand equals to BMW.

Can the "earlier" executed "delete by query"-call affect documents indexed by the bulk index?

Thanks,  
Anton

---

<div class="post-metadata">

**Author:** ![JKhondhu](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@JKhondhu](https://discuss.elastic.co/u/JKhondhu)\
**Post date:** [December 1, 2017, 9:39am UTC](https://discuss.elastic.co/t/bulk-indexing-depending-on-a-delete-by-query/109901/2 "2017-12-01T09:39:37Z")

</div>

Hi,  
It would be interesting to understand the use case whereby you want to delete the 5 BMW docs before indexing 10 new. Such as a car dealership? Delete 5 old stock and index 10 of the latest?

I see not reason why a delete would the falter the subsequent bulk. They will use their own threads.

See here if you are interested in using the _conflicts_ parameter with the \__delete\_by\_query_ : [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html)

---

<div class="post-metadata">

**Author:** ![antonkallenberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/antonkallenberg/32/6259_2.png) [@antonkallenberg](https://discuss.elastic.co/u/antonkallenberg)\
**Post date:** [December 1, 2017, 9:51am UTC](https://discuss.elastic.co/t/bulk-indexing-depending-on-a-delete-by-query/109901/3 "2017-12-01T09:51:15Z")

</div>

Hi Jymit,

Thanks for your reply!

The case is a bit simplified, when indexing we don't know which docs that should be deleted, indexed or re-indexed because the "key" (within the primary car-storage) for the car-document is changing between every bulk-index.

So the simplest solution for us would be to delete all docs by a given category then re-index all documents for that category, maybe that's a bad idea?

---

<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:** [December 29, 2017, 9:51am UTC](https://discuss.elastic.co/t/bulk-indexing-depending-on-a-delete-by-query/109901/4 "2017-12-29T09:51:16Z")

</div>

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