Synchronization problems


(Magnus Poromaa) #1

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


(Binh Ly-2) #2

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


(system) #3