String mongoDocument = copyToStringFromClasspath(TEST_SIMPLE_MONGODB_DOCUMENT_JSON);
DBObject dbObject = (DBObject) JSON.parse(mongoDocument);
mongoCollection.insert(dbObject);
Thread.sleep(wait);
assertThat(getNode().client().admin().indices().exists(new IndicesExistsRequest(getIndex())).actionGet().isExists(),
equalTo(true));
assertThat(getNode().client().admin().indices().prepareTypesExists(getIndex()).setTypes(getDatabase()).execute().actionGet()
.isExists(), equalTo(true));
long countRequest = getNode().client().count(countRequest(getIndex())).actionGet().getCount();
mongoDB.dropDatabase();
Thread.sleep(wait);
assertThat(databaseExists(getDatabase()), equalTo(false));
Thread.sleep(wait);
refreshIndex();
if (!dropCollectionOption) {
countRequest = getNode().client().count(countRequest(getIndex())).actionGet().getCount();
assertThat(countRequest, greaterThan(0L));
} else {
countRequest = getNode().client().count(countRequest(getIndex())).actionGet().getCount();
assertThat(countRequest, equalTo(0L));
}
mongoDB = getMongo().getDB(getDatabase());
mongoCollection = mongoDB.createCollection(getCollection(), null);
dbObject = (DBObject) JSON.parse(mongoDocument);
String value = String.valueOf(System.currentTimeMillis());
dbObject.put("attribute1", value);
mongoCollection.insert(dbObject);
Thread.sleep(wait);
assertThat(getNode().client().admin().indices().exists(new IndicesExistsRequest(getIndex())).actionGet().isExists(),
equalTo(true));
assertThat(getNode().client().admin().indices().prepareTypesExists(getIndex()).setTypes(getDatabase()).execute().actionGet()
.isExists(), equalTo(true));
CountResponse countResponse = getNode().client().prepareCount(getIndex())
.setQuery(QueryBuilders.queryString(value).defaultField("attribute1")).get();