# BulkRequestBuilder is slow

**URL:** <https://discuss.elastic.co/t/bulkrequestbuilder-is-slow/11426>\
**Category:** Elasticsearch\
**Created:** [April 3, 2013, 6:10am UTC](https://discuss.elastic.co/t/bulkrequestbuilder-is-slow/11426 "2013-04-03T06:10:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![muzammil\_abdul](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@muzammil\_abdul](https://discuss.elastic.co/u/muzammil_abdul)\
**Post date:** [April 3, 2013, 6:10am UTC](https://discuss.elastic.co/t/bulkrequestbuilder-is-slow/11426/1 "2013-04-03T06:10:38Z")

</div>

I am trying to index and remove some document in the index  
using BulkRequestBuilder java api. When I execute the bulk the changes in  
the index is not happening immediately. If I do some delete operation using  
the bulk after quite long time the data is getting deleted from the index.  
Is there any property to be set to make the changes get reflected in the  
index immediately after the bulk execution.

Thanks in advance.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 3, 2013, 6:20am UTC](https://discuss.elastic.co/t/bulkrequestbuilder-is-slow/11426/2 "2013-04-03T06:20:46Z")

</div>

Hey,

the refresh API might help you in this case after you finished indexing...  
however unless you changed your configuration, a 'quite long time' should  
be very short...

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Wed, Apr 3, 2013 at 8:10 AM, [muzammil.abdul@enhancesys.com](mailto:muzammil.abdul@enhancesys.com) wrote:

> I am trying to index and remove some document in the index  
> using BulkRequestBuilder java api. When I execute the bulk the changes in  
> the index is not happening immediately. If I do some delete operation using  
> the bulk after quite long time the data is getting deleted from the index.  
> Is there any property to be set to make the changes get reflected in the  
> index immediately after the bulk execution.
> 
> Thanks in advance.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![muzammil\_abdul](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@muzammil\_abdul](https://discuss.elastic.co/u/muzammil_abdul)\
**Post date:** [April 3, 2013, 6:28am UTC](https://discuss.elastic.co/t/bulkrequestbuilder-is-slow/11426/3 "2013-04-03T06:28:04Z")

</div>

Thanks for ur reply Mr.Alexander Reelsen. Any how I had  
set setRefresh(true) to my bulkRequestBuilder after setting this I was able  
to search for the documents that I had indexed using the bulk but the the  
documents which I had deleted using the bulk remains unchanged

I am using elasticSearch 19.8 - Java api

With regards  
Muzammil A

On Wednesday, April 3, 2013 11:50:46 AM UTC+5:30, Alexander Reelsen wrote:

> Hey,
> 
> the refresh API might help you in this case after you finished indexing...  
> however unless you changed your configuration, a 'quite long time' should  
> be very short...  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh/)
> 
> On Wed, Apr 3, 2013 at 8:10 AM, \<[muzammi...@enhancesys.com](mailto:muzammi...@enhancesys.com) \<javascript:\>\>wrote:
> 
> > I am trying to index and remove some document in the index  
> > using BulkRequestBuilder java api. When I execute the bulk the changes in  
> > the index is not happening immediately. If I do some delete operation using  
> > the bulk after quite long time the data is getting deleted from the index.  
> > Is there any property to be set to make the changes get reflected in the  
> > index immediately after the bulk execution.
> > 
> > Thanks in advance.
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [April 3, 2013, 7:46am UTC](https://discuss.elastic.co/t/bulkrequestbuilder-is-slow/11426/4 "2013-04-03T07:46:05Z")

</div>

Document deletes just mark documents as deleted until next segment  
merge. To enforce visibility of deleted documents to all index readers,  
you must optimize the index (to trigger a segment merge). Note, using  
refresh/optimize is very harmful to performance.

Jörg

Am 03.04.13 08:28, schrieb [muzammil.abdul@enhancesys.com](mailto:muzammil.abdul@enhancesys.com):

> Any how I had set setRefresh(true) to my bulkRequestBuilder after  
> setting this I was able to search for the documents that I had indexed  
> using the bulk but the the documents which I had deleted using the  
> bulk remains unchanged

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![muzammil\_abdul](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@muzammil\_abdul](https://discuss.elastic.co/u/muzammil_abdul)\
**Post date:** [April 3, 2013, 9:03am UTC](https://discuss.elastic.co/t/bulkrequestbuilder-is-slow/11426/5 "2013-04-03T09:03:20Z")

</div>

Hi Jorg Prante,

You mean than I need to do the following coding

OptimizeRequest optimize = new OptimizeRequest();  
optimize.waitForMerge(false);  
client.admin().indices().optimize(optimize);

I just want to know that I am doing it right.

On Wed, Apr 3, 2013 at 1:16 PM, Jörg Prante [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:

> Document deletes just mark documents as deleted until next segment merge.  
> To enforce visibility of deleted documents to all index readers, you must  
> optimize the index (to trigger a segment merge). Note, using  
> refresh/optimize is very harmful to performance.
> 
> Jörg
> 
> Am 03.04.13 08:28, schrieb [muzammil.abdul@enhancesys.com](mailto:muzammil.abdul@enhancesys.com):
> 
> Any how I had set setRefresh(true) to my bulkRequestBuilder after setting
> 
> > this I was able to search for the documents that I had indexed using the  
> > bulk but the the documents which I had deleted using the bulk remains  
> > unchanged
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)\*\*  
> topic/elasticsearch/\*\*n5rJuEtVQtA/unsubscribe?hl=en-\*\*US[https://groups.google.com/d/topic/elasticsearch/n5rJuEtVQtA/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/n5rJuEtVQtA/unsubscribe?hl=en-US)  
> .  
> To unsubscribe from this group and all its topics, send an email to  
> elasticsearch+unsubscribe@\*\*[googlegroups.com](http://googlegroups.com)[elasticsearch%2Bunsubscribe@googlegroups.com](mailto:elasticsearch%2Bunsubscribe@googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> .

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [April 3, 2013, 10:00am UTC](https://discuss.elastic.co/t/bulkrequestbuilder-is-slow/11426/6 "2013-04-03T10:00:03Z")

</div>

You must wait for delete expunges if you want to be sure each delete has  
been executed.

```
     OptimizeRequest request = new 

```

OptimizeRequest().onlyExpungeDeletes(true).waitForMerge(true);  
client.admin().indices().optimize(request).actionGet();

Note, I strongly recommend against using this feature for each document  
you delete unless you know that you are destroying all the performance  
ES can offer.

Jörg

Am 03.04.13 11:03, schrieb Muzammil A:

> Hi Jorg Prante,
> 
> You mean than I need to do the following coding
> 
> OptimizeRequest optimize = new OptimizeRequest();  
> optimize.waitForMerge(false);  
> client.admin().indices().optimize(optimize);
> 
> I just want to know that I am doing it right.
> 
> On Wed, Apr 3, 2013 at 1:16 PM, Jörg Prante \<[joergprante@gmail.com](mailto:joergprante@gmail.com)  
> [mailto:joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> 
> ```
> Document deletes just mark documents as deleted until next segment
> merge. To enforce visibility of deleted documents to all index
> readers, you must optimize the index (to trigger a segment merge).
> Note, using refresh/optimize is very harmful to performance.
> 
> Jörg
> 
> Am 03.04.13 08:28, schrieb muzammil.abdul@enhancesys.com
> <mailto:muzammil.abdul@enhancesys.com>:
> 
> Any how I had set setRefresh(true) to my bulkRequestBuilder
> after setting this I was able to search for the documents that
> I had indexed using the bulk but the the documents which I had
> deleted using the bulk remains unchanged
> 
> -- 
> You received this message because you are subscribed to a topic in
> the Google Groups "elasticsearch" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elasticsearch/n5rJuEtVQtA/unsubscribe?hl=en-US.
> To unsubscribe from this group and all its topics, send an email
> to elasticsearch+unsubscribe@googlegroups.com
> <mailto:elasticsearch%2Bunsubscribe@googlegroups.com>.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> ```
> 
> --  
> You received this message because you are subscribed to the Google  
> Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send  
> an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:43am UTC](https://discuss.elastic.co/t/bulkrequestbuilder-is-slow/11426/7 "2017-07-06T02:43:05Z")

</div>


