String authorId = dbObject.get("_id").toString();
logger.info("WriteResult: {}", result.toString());
refreshIndex(INDEX_NAME);
ActionFuture<IndicesExistsResponse> response = getNode().client().admin().indices()
.exists(new IndicesExistsRequest(INDEX_NAME));
assertThat(response.actionGet().isExists(), equalTo(true));
SearchResponse sr = getNode().client().prepareSearch(INDEX_NAME).setQuery(QueryBuilders.queryString(authorId).defaultField("_id")).execute().actionGet();
logger.debug("SearchResponse {}", sr.toString());
long totalHits = sr.getHits().getTotalHits();
logger.debug("TotalHits: {}", totalHits);
assertThat(totalHits, equalTo(1l));
String book1Document = copyToStringFromClasspath(BOOK1_DOCUMENT_JSON);
dbObject = (DBObject) JSON.parse(book1Document);
result = mongoBooksCollection.insert(dbObject);
Thread.sleep(wait);
String bookId = dbObject.get("_id").toString();
logger.info("WriteResult: {}", result.toString());
refreshIndex(INDEX_NAME);
response = getNode().client().admin().indices().exists(new IndicesExistsRequest(INDEX_NAME));
assertThat(response.actionGet().isExists(), equalTo(true));
sr = getNode().client().prepareSearch(INDEX_NAME).setQuery(QueryBuilders.queryString(bookId).defaultField("_id")).execute().actionGet();
logger.debug("SearchResponse {}", sr.toString());
totalHits = sr.getHits().getTotalHits();