Strange behavior with Java API

Hi,

I'm trying out elasticsearch (0.15.0) through the Java API. To do so, I
wrote a simple unit test that starts an embedded instance, indexes a
document, then searches for the document:

If I remove the WriteConsistencyLevel.QUORUM setting from the indexing
operation, then about half of the time, even after a refresh, I fail to find
the document at search time (I thought the default consistency level was
QUORUM or ALL).

If I change the write consistency to WriteConsistencyLevel.ALL, then the
test seems to hang at the indexing step.

Any ideas?

Curtis

Heya, setting the write consistency is not relevant to this case (since the index request will wait for at least one shard to be available already, and with 1 replica, it does not matter). But, there is a problem (only applies when a new index is being allocated): Searching while an index is being allocated and no active shards exists within a "shard replication group" can cause search "misses" · Issue #736 · elastic/elasticsearch · GitHub (already fixed).

Note, if you use the cluster health API after you create the index and wait for yellow status, then this problem will not happen.

-shay.banon
On Wednesday, March 2, 2011 at 4:05 AM, Curtis Caravone wrote:

Hi,

I'm trying out elasticsearch (0.15.0) through the Java API. To do so, I wrote a simple unit test that starts an embedded instance, indexes a document, then searches for the document: Unit test with embedded elasticsearch · GitHub

If I remove the WriteConsistencyLevel.QUORUM setting from the indexing operation, then about half of the time, even after a refresh, I fail to find the document at search time (I thought the default consistency level was QUORUM or ALL).

If I change the write consistency to WriteConsistencyLevel.ALL, then the test seems to hang at the indexing step.

Any ideas?

Curtis