Elastic search CRUD function only working in debug mode


#1

Issue details:

Elasticsearch CRUD function only working in debug mode, not in normal mode.(while running in eclipse debug mode)

Or else if we put Thread .sleep(5000),then also it is working(without debug mode) but impact the performance. .

other details used in application:

-Elasticsearch client is spring autowired (@autowired Client)
-Using elasticsearch node in spring config file as -

elasticsearch:node-client id="client" local="true">

sample query used for create and get:
client.prepareIndex(index, type, id).setSource(json).execute().actionGet();
Thread .sleep(5000)

GetResponse getResponse = client.prepareGet().execute().actionGet();

Noticed that , in debug mode or when run with Thread .sleep(5000):
the shard remains the same for all the documents added eg: shard = [hR-0yqwrS2aVkQFC-kk1VA]

But when run in the normal mode or without Thread .sleep(5000):

for each addition of the document,the shard is changing:

shard = [L1t7yr_2RNWqH3zvHutrcg] for document id=1

shard = [qIIznu1rRoyXqBabz3YLZQ] for document id=2

shard = [uwQAAXMNR8aJPmT59fnjgg] for document id=3

Pls let me know for any more details required.
Appreciate a lot,if get quick response .Many thanks in advance.

code snippet JUNIT:
@Test
public void testAddCustomer() {
String success = "document created";
try {
int k=1;//this value,I am changing for adding many document with diff id.

		create sample CustomerTest object(customerVo).
                    addCustomer(customerVo);
	} catch (Exception ex) {
		success = "document creation failed";
	}

	assertEquals("document created", success);
	}	

@After
public void after() {
	
	searchAllCount(); 
}

#2

tried putting refresh,but no luck.

client.admin().indices().prepareRefresh(index).execute().actionGet();

I am new user to the elastic search.Would like to implement it as part of our organisation search tool.May be missing something obvious and basic.Any help could be much appreciated.


(system) #3