use of org.elasticsearch.action.get.GetResponse in project camel by apache.
the class ElasticsearchGetSearchDeleteExistsUpdateTest method testDelete.
@Test
public void testDelete() throws Exception {
//first, INDEX a value
Map<String, String> map = createIndexedData();
sendBody("direct:index", map);
String indexId = template.requestBody("direct:index", map, String.class);
assertNotNull("indexId should be set", indexId);
//now, verify GET succeeded
GetResponse response = template.requestBody("direct:get", indexId, GetResponse.class);
assertNotNull("response should not be null", response);
assertNotNull("response source should not be null", response.getSource());
//now, perform DELETE
DeleteResponse deleteResponse = template.requestBody("direct:delete", indexId, DeleteResponse.class);
assertNotNull("response should not be null", deleteResponse);
//now, verify GET fails to find the indexed value
response = template.requestBody("direct:get", indexId, GetResponse.class);
assertNotNull("response should not be null", response);
assertNull("response source should be null", response.getSource());
}
use of org.elasticsearch.action.get.GetResponse in project camel by apache.
the class ElasticsearchGetSearchDeleteExistsUpdateTest method testGetWithHeaders.
@Test
public void testGetWithHeaders() throws Exception {
//first, INDEX a value
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "tweet");
String indexId = template.requestBodyAndHeaders("direct:start", map, headers, String.class);
//now, verify GET
headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_GET_BY_ID);
GetResponse response = template.requestBodyAndHeaders("direct:start", indexId, headers, GetResponse.class);
assertNotNull("response should not be null", response);
assertNotNull("response source should not be null", response.getSource());
}
use of org.elasticsearch.action.get.GetResponse in project camel by apache.
the class ElasticsearchGetSearchDeleteExistsUpdateTest method testGet.
@Test
public void testGet() throws Exception {
//first, INDEX a value
Map<String, String> map = createIndexedData();
sendBody("direct:index", map);
String indexId = template.requestBody("direct:index", map, String.class);
assertNotNull("indexId should be set", indexId);
//now, verify GET succeeded
GetResponse response = template.requestBody("direct:get", indexId, GetResponse.class);
assertNotNull("response should not be null", response);
assertNotNull("response source should not be null", response.getSource());
}
use of org.elasticsearch.action.get.GetResponse in project jena by apache.
the class TextIndexESIT method testAddEntity.
@Test
public void testAddEntity() {
String labelKey = "label";
String labelValue = "this is a sample Label";
Assert.assertNotNull(classToTest);
Entity entityToAdd = entity("http://example/x3", labelKey, labelValue);
GetResponse response = addEntity(entityToAdd);
Assert.assertTrue(response.getSource().containsKey(labelKey));
Assert.assertEquals(labelValue, ((List<?>) response.getSource().get(labelKey)).get(0));
}
use of org.elasticsearch.action.get.GetResponse in project jena by apache.
the class TextIndexESIT method testDeleteWhenNoneExists.
@Test
public void testDeleteWhenNoneExists() {
GetResponse response = transportClient.prepareGet(INDEX_NAME, DOC_TYPE, "http://example/x3").get();
Assert.assertFalse(response.isExists());
Assert.assertNotNull(classToTest);
classToTest.deleteEntity(entity("http://example/x3", "label", "doesnt matter"));
response = transportClient.prepareGet(INDEX_NAME, DOC_TYPE, "http://example/x3").get();
Assert.assertFalse(response.isExists());
}
Aggregations