Stale data retuned after index request


(Andrius Juozapaitis) #1

Hey,

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

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


(Igor Motov) #2

Updates become available after index refresh. Refresh can be triggered
manually (see
http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh.html)
or it can be scheduled to run periodically (see index.refresh_interval in
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:

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


(Andrius Juozapaitis) #3

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
http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh.html)
or it can be scheduled to run periodically (see index.refresh_interval in
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:

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


(system) #4