use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.get.GetResponse in project alien4cloud by alien4cloud.
the class EsDaoSearchTest method assertDocumentExisit.
private void assertDocumentExisit(String indexName, String typeName, String id, boolean expected) {
GetResponse response = getDocument(indexName, typeName, id);
assertEquals(expected, response.isExists());
assertEquals(expected, !response.isSourceEmpty());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.get.GetResponse in project alien4cloud by alien4cloud.
the class EsDaoSuggestionTest method assertDocumentExisit.
private void assertDocumentExisit(String indexName, String typeName, String id, boolean expected) {
GetResponse response = getDocument(indexName, typeName, id);
assertEquals(expected, response.isExists());
assertEquals(expected, !response.isSourceEmpty());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.get.GetResponse in project fess-crawler by codelibs.
the class AbstractCrawlerService method get.
protected <T> T get(final Class<T> clazz, final String sessionId, final String url) {
final String id = getId(sessionId, url);
final GetResponse response = getClient().get(c -> c.prepareGet(index, type, id).execute());
if (response.isExists()) {
final Map<String, Object> source = response.getSource();
final T bean = BeanUtil.copyMapToNewBean(source, clazz, option -> {
option.converter(new EsTimestampConverter(), timestampFields).excludeWhitespace();
option.exclude(EsAccessResult.ACCESS_RESULT_DATA);
});
@SuppressWarnings("unchecked") final Map<String, Object> data = (Map<String, Object>) source.get(EsAccessResult.ACCESS_RESULT_DATA);
if (data != null) {
((EsAccessResult) bean).setAccessResultData(new EsAccessResultData(data));
}
setId(bean, id);
return bean;
}
return null;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.get.GetResponse in project elasticsearch-river-couchdb by elastic.
the class CouchdbRiverIntegrationTest method testCreateCouchdbDatabaseWhileRunning_17.
/**
* Test case for #17: https://github.com/elasticsearch/elasticsearch-river-couchdb/issues/17
*/
@Test
public void testCreateCouchdbDatabaseWhileRunning_17() throws IOException, InterruptedException {
final int nbDocs = between(50, 300);
logger.info(" -> Checking couchdb running");
CouchDBClient.checkCouchDbRunning();
logger.info(" -> Create index");
try {
createIndex(getDbName());
} catch (IndexAlreadyExistsException e) {
// No worries. We already created the index before
}
logger.info(" -> Create river");
index("_river", getDbName(), "_meta", jsonBuilder().startObject().field("type", "couchdb").endObject());
// Check that the river is started
assertThat(awaitBusy(new Predicate<Object>() {
public boolean apply(Object obj) {
try {
refresh();
GetResponse response = get("_river", getDbName(), "_status");
return response.isExists();
} catch (IndexMissingException e) {
return false;
}
}
}, 5, TimeUnit.SECONDS), equalTo(true));
logger.info(" -> Creating test database [{}]", getDbName());
CouchDBClient.dropAndCreateTestDatabase(getDbName());
logger.info(" -> Inserting [{}] docs in couchdb", nbDocs);
for (int i = 0; i < nbDocs; i++) {
CouchDBClient.putDocument(getDbName(), "" + i, "foo", "bar", "content", "" + i);
}
// Check that docs are still processed by the river
assertThat(awaitBusy(new Predicate<Object>() {
public boolean apply(Object obj) {
try {
refresh();
SearchResponse response = client().prepareSearch(getDbName()).get();
logger.info(" -> got {} docs in {} index", response.getHits().totalHits(), getDbName());
return response.getHits().totalHits() == nbDocs;
} catch (IndexMissingException e) {
return false;
}
}
}, 1, TimeUnit.MINUTES), equalTo(true));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.get.GetResponse in project flink by apache.
the class TestClientBase method assertThatIdsAreNotWritten.
void assertThatIdsAreNotWritten(String index, int... ids) throws IOException {
for (final int id : ids) {
try {
final GetResponse response = getResponse(index, id);
assertFalse(response.isExists(), String.format("Id %s is unexpectedly present.", id));
} catch (ElasticsearchStatusException e) {
assertEquals(404, e.status().getStatus());
}
}
}
Aggregations