# Disabling indexing during bulk publishing using the java api

**URL:** <https://discuss.elastic.co/t/disabling-indexing-during-bulk-publishing-using-the-java-api/9254>\
**Category:** Elasticsearch\
**Created:** [October 5, 2012, 3:32pm UTC](https://discuss.elastic.co/t/disabling-indexing-during-bulk-publishing-using-the-java-api/9254 "2012-10-05T15:32:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Russell\_Snyder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_snyder/32/2697_2.png) [@Russell\_Snyder](https://discuss.elastic.co/u/Russell_Snyder)\
**Post date:** [October 5, 2012, 3:32pm UTC](https://discuss.elastic.co/t/disabling-indexing-during-bulk-publishing-using-the-java-api/9254/1 "2012-10-05T15:32:19Z")

</div>

Hi,

We're trying to load 400k documents using the java bulk api (Client  
and BulkRequestBuilder) and are running into some timeout issues that we  
think could be remedied by disabling indexing during the publish, then  
re-enabling immediately upon publish completion. Is there a way to use the  
Client to execute the below PUT call, or something similar?

curl -XPUT localhost:9200/test/\_settings -d '{  
"index" : {  
"refresh\_interval" : "-1"  
}  
}'

Any Ideas or suggestions for tuning elasticsearch to better handle a  
massive amount of writes?

Thanks,  
Russell

--

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 5, 2012, 4:33pm UTC](https://discuss.elastic.co/t/disabling-indexing-during-bulk-publishing-using-the-java-api/9254/2 "2012-10-05T16:33:36Z")

</div>

Here is a long way to update the settings via the client:

ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();  
settings.put("refresh\_interval", -1);  
UpdateSettingsRequest updateSettingsRequest = new  
UpdateSettingsRequest(indexName);  
updateSettingsRequest.settings(updateSettings);  
client.admin().indices().updateSettings(updateSettingsRequest).actionGet();

Setting the refresh interval to -1 is the only setting I change before bulk  
indexing to a live index. For new indices, I remove all replicas first and  
add them in after indexing is done (waiting for a green state before  
actually using the index). Indexing should be completely under your control  
unless you are using a river. Can you implement a singleton that controls  
indexing?

Cheers,

Ivan

On Fri, Oct 5, 2012 at 8:32 AM, Russell Snyder  
[russell@redowlanalytics.com](mailto:russell@redowlanalytics.com)wrote:

> Hi,
> 
> We're trying to load 400k documents using the java bulk api (Client  
> and BulkRequestBuilder) and are running into some timeout issues that we  
> think could be remedied by disabling indexing during the publish, then  
> re-enabling immediately upon publish completion. Is there a way to use the  
> Client to execute the below PUT call, or something similar?
> 
> curl -XPUT localhost:9200/test/\_settings -d '{  
> "index" : {  
> "refresh\_interval" : "-1"  
> }  
> }'
> 
> Any Ideas or suggestions for tuning elasticsearch to better handle a  
> massive amount of writes?
> 
> Thanks,  
> Russell
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Russell\_Snyder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_snyder/32/2697_2.png) [@Russell\_Snyder](https://discuss.elastic.co/u/Russell_Snyder)\
**Post date:** [October 5, 2012, 5:12pm UTC](https://discuss.elastic.co/t/disabling-indexing-during-bulk-publishing-using-the-java-api/9254/3 "2012-10-05T17:12:17Z")

</div>

Ivan,

Thanks for the response. That sounds like a pretty viable solution, and  
I'll give it a try shortly.

Thanks,  
Russell

On Friday, October 5, 2012 11:32:19 AM UTC-4, Russell Snyder wrote:

> Hi,
> 
> We're trying to load 400k documents using the java bulk api (Client  
> and BulkRequestBuilder) and are running into some timeout issues that we  
> think could be remedied by disabling indexing during the publish, then  
> re-enabling immediately upon publish completion. Is there a way to use the  
> Client to execute the below PUT call, or something similar?
> 
> curl -XPUT localhost:9200/test/\_settings -d '{  
> "index" : {  
> "refresh\_interval" : "-1"  
> }  
> }'
> 
> Any Ideas or suggestions for tuning elasticsearch to better handle a  
> massive amount of writes?
> 
> Thanks,  
> Russell

--

---

<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, 3:09am UTC](https://discuss.elastic.co/t/disabling-indexing-during-bulk-publishing-using-the-java-api/9254/4 "2017-07-06T03:09:56Z")

</div>


