# Slow updates with prepareIndex Java API

**URL:** <https://discuss.elastic.co/t/slow-updates-with-prepareindex-java-api/8291>\
**Category:** Elasticsearch\
**Created:** [July 3, 2012, 2:21am UTC](https://discuss.elastic.co/t/slow-updates-with-prepareindex-java-api/8291 "2012-07-03T02:21:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbala](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pbala](https://discuss.elastic.co/u/pbala)\
**Post date:** [July 3, 2012, 2:21am UTC](https://discuss.elastic.co/t/slow-updates-with-prepareindex-java-api/8291/1 "2012-07-03T02:21:24Z")

</div>

Hi,

I'm a bit new to ElasticSearch so a bit stuck on this problem:

We use a prepareIndex query to elasticSearch (v 0.18.4) using the Java API

```
           client.prepareIndex(index,valueType, key)

               .setSource(json)

               .execute()

               .actionGet()

```

However, the update in elasticSearch takes a while (magnitude of hours) to  
show up. Are there any settings in elastic search that we need to be aware  
of which can help us amend this and get immediate updates?

We have 1 replica, 5 shards. It used to immediately update until recently  
and we've tried flushing the index and that doesn't help either.

Thanks

---

<div class="post-metadata">

**Author:** ![drewr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewr/32/7803_2.png) [@drewr](https://discuss.elastic.co/u/drewr)\
**Post date:** [July 3, 2012, 2:09pm UTC](https://discuss.elastic.co/t/slow-updates-with-prepareindex-java-api/8291/2 "2012-07-03T14:09:16Z")

</div>

pbala wrote:

> We use a prepareIndex query to elasticSearch (v 0.18.4) using the Java API
> 
> ```
> client.prepareIndex(index,valueType, key)
> .setSource(json)
> .execute()
> .actionGet()
> 
> ```
> 
> However, the update in elasticSearch takes a while (magnitude of  
> hours) to show up. Are there any settings in Elasticsearch that we  
> need to be aware of which can help us amend this and get immediate  
> updates?

You need to refresh the index. If you're just doing an individual  
index operation and you want to see the results show up in search,  
you should perform a client.admin().indices().prepareRefresh(index)  
afterward.

If you need to change ES's default refresh interval, you can change  
this value to something within a few min:

index.engine.robin.refresh\_interval: 5m

Don't drop that too low though because it will slow indexing  
considerably while ES has to wait for disk IO.

-Drew

---

<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:21am UTC](https://discuss.elastic.co/t/slow-updates-with-prepareindex-java-api/8291/3 "2017-07-06T03:21:39Z")

</div>


