# Synchronization problems

**URL:** <https://discuss.elastic.co/t/synchronization-problems/17043>\
**Category:** Elasticsearch\
**Created:** [April 16, 2014, 9:23am UTC](https://discuss.elastic.co/t/synchronization-problems/17043 "2014-04-16T09:23:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Magnus\_Poromaa](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@Magnus\_Poromaa](https://discuss.elastic.co/u/Magnus_Poromaa)\
**Post date:** [April 16, 2014, 9:23am UTC](https://discuss.elastic.co/t/synchronization-problems/17043/1 "2014-04-16T09:23:01Z")

</div>

Hi

So I start a local cluster and place and index in it. The settings are

ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder()  
.put("node.name", "node-test-" + System.currentTimeMillis())  
.put("node.data", true)  
.put("cluster.name", "cluster-test-" +  
NetworkUtils.getLocalAddress().getHostName())  
.put("index.store.type", "memory")  
.put("index.store.fs.memory.enabled", "true")  
.put("gateway.type", "none")  
.put("path.data", "./target/elasticsearch-test/data")  
.put("path.work", "./target/elasticsearch-test/work")  
.put("path.logs", "./target/elasticsearch-test/logs")  
.put("index.number\_of\_shards", "1")  
.put("index.number\_of\_replicas", "0")  
.put("cluster.routing.schedule", "50ms")  
.put("node.local", true);

So in the test after placing the index I do a search query like this

SearchResponse response = client.prepareSearch(INSTRUMENTS\_INDEX)  
.setTypes(INSTRUMENT\_TYPE)  
.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)

.setQuery(QueryBuilders.queryString(instrumentQuery.getQuery()))  
.execute()  
.actionGet();

WHere the query is really pointing to the index I created.

So the problem is that if i run this like this

1. Create index
2. Execute query

I get 0 results back BUT if I run it like this

1. Create Index
2. Thread.sleep(1000)
3. Execute query

I get 1 result back.

So of cause this has to have something to do with the files being taken  
away between running each test bacus eif I keep them around it works  
without the sleep. Is there some sort of synchronization  
or transaction status I need to check after creating the index to be  
guaranteed it is in the storage BEFORE executing the query ?

Thanks

Magnus

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/33365892-ec1f-4feb-8918-dbbffe02ff1f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/33365892-ec1f-4feb-8918-dbbffe02ff1f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [April 16, 2014, 5:30pm UTC](https://discuss.elastic.co/t/synchronization-problems/17043/2 "2014-04-16T17:30:43Z")

</div>

There is a near-realtime aspect to ES. What this means is by default,  
documents are searchable within 1 second (refresh interval) after they are  
indexed. You may index a document and explicitly refresh it immediately in  
which case, you can search for it immediately. For example:

client.prepareIndex("index", "type1").setSource(doc).setId("1").  
_setRefresh(true)_.execute().actionGet();

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a2d0a8f0-f1c1-4f88-8794-0417de11c60c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a2d0a8f0-f1c1-4f88-8794-0417de11c60c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:35am UTC](https://discuss.elastic.co/t/synchronization-problems/17043/3 "2017-07-06T01:35:27Z")

</div>


