# Stale data retuned after index request

**URL:** <https://discuss.elastic.co/t/stale-data-retuned-after-index-request/7337>\
**Category:** Elasticsearch\
**Created:** [April 15, 2012, 10:08pm UTC](https://discuss.elastic.co/t/stale-data-retuned-after-index-request/7337 "2012-04-15T22:08:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrius\_Juozapaitis](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@Andrius\_Juozapaitis](https://discuss.elastic.co/u/Andrius_Juozapaitis)\
**Post date:** [April 15, 2012, 10:08pm UTC](https://discuss.elastic.co/t/stale-data-retuned-after-index-request/7337/1 "2012-04-15T22:08:01Z")

</div>

Hey,

I am probably just missing something obvious, but I am getting stale data  
when searching right after the index update:

```auto
Settings settings = 
ImmutableSettings.settingsBuilder().put("client.transport.sniff", 
true).build();
TransportClient client = new 
TransportClient(settings).addTransportAddress(new 
InetSocketTransportAddress(host, port));
IndexResponse indexResponse = client.index(source).actionGet();
client.setQuery(matchAllQuery()).execute().get();
```

I thought index operation was synchronous? If I add a tiny delay between  
the index and search operations, the updated data is being returned. I only  
have a single node, no replication, with default settings. Can anyone point  
me to the right direction here please?

regards,  
Andrius Juozapaitis

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 16, 2012, 1:41pm UTC](https://discuss.elastic.co/t/stale-data-retuned-after-index-request/7337/2 "2012-04-16T13:41:11Z")

</div>

Updates become available after index refresh. Refresh can be triggered  
manually (see  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh.html))  
or it can be scheduled to run periodically (see index.refresh\_interval in  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/index.html))

On Sunday, April 15, 2012 6:08:01 PM UTC-4, Andrius Juozapaitis wrote:

> Hey,
> 
> I am probably just missing something obvious, but I am getting stale data  
> when searching right after the index update:
> 
> ```auto
> Settings settings = 
> > ImmutableSettings.settingsBuilder().put("client.transport.sniff", 
> > true).build();
> > TransportClient client = new 
> > TransportClient(settings).addTransportAddress(new 
> > InetSocketTransportAddress(host, port));
> > IndexResponse indexResponse = client.index(source).actionGet();
> > client.setQuery(matchAllQuery()).execute().get();
> ```
> 
> I thought index operation was synchronous? If I add a tiny delay between  
> the index and search operations, the updated data is being returned. I only  
> have a single node, no replication, with default settings. Can anyone point  
> me to the right direction here please?
> 
> regards,  
> Andrius Juozapaitis

---

<div class="post-metadata">

**Author:** ![Andrius\_Juozapaitis](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@Andrius\_Juozapaitis](https://discuss.elastic.co/u/Andrius_Juozapaitis)\
**Post date:** [April 16, 2012, 2:07pm UTC](https://discuss.elastic.co/t/stale-data-retuned-after-index-request/7337/3 "2012-04-16T14:07:14Z")

</div>

Thanks Igor, much appreciated!

regards,  
Andrius

On Monday, April 16, 2012 4:41:11 PM UTC+3, Igor Motov wrote:

> Updates become available after index refresh. Refresh can be triggered  
> manually (see  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh.html))  
> or it can be scheduled to run periodically (see index.refresh\_interval in  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/index.html))
> 
> On Sunday, April 15, 2012 6:08:01 PM UTC-4, Andrius Juozapaitis wrote:
> 
> > Hey,
> > 
> > I am probably just missing something obvious, but I am getting stale data  
> > when searching right after the index update:
> > 
> > ```auto
> > Settings settings = 
> > >> ImmutableSettings.settingsBuilder().put("client.transport.sniff", 
> > >> true).build();
> > >> TransportClient client = new 
> > >> TransportClient(settings).addTransportAddress(new 
> > >> InetSocketTransportAddress(host, port));
> > >> IndexResponse indexResponse = client.index(source).actionGet();
> > >> client.setQuery(matchAllQuery()).execute().get();
> > ```
> > 
> > I thought index operation was synchronous? If I add a tiny delay between  
> > the index and search operations, the updated data is being returned. I only  
> > have a single node, no replication, with default settings. Can anyone point  
> > me to the right direction here please?
> > 
> > regards,  
> > Andrius Juozapaitis

---

<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:32am UTC](https://discuss.elastic.co/t/stale-data-retuned-after-index-request/7337/4 "2017-07-06T03:32:27Z")

</div>


