I am using Elasticsearch java high level rest client and synchronous API calls are hanging forever in onResponse method
public String indexDocument(String document) throws Exception {
IndexRequest indexRequest = new IndexRequest("myindex")
.source(document, XContentType.JSON);
ActionListener<IndexResponse> listener;
listener = new ActionListener<IndexResponse>() {
@Override
public void onResponse(IndexResponse indexResponse) {
try {
// This call is hanging forever
RefreshResponse refreshResponse = client.indices().refresh(new RefreshRequest("myindex"), RequestOptions.DEFAULT);
System.out.println(refreshResponse.getSuccessfulShards());
}
catch(Exception e) {
}
}
@Override
public void onFailure(Exception e) {
e.printStackTrace();
}
};
client.indexAsync(indexRequest, RequestOptions.DEFAULT, listener);
}