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());
}
use of org.elasticsearch.action.get.GetResponse in project jena by apache.
the class TextIndexES method get.
/**
* Get an Entity given the subject Id
* @param uri the subject Id of the entity
* @return a map of field name and field values;
*/
@Override
public Map<String, Node> get(String uri) {
GetResponse response;
Map<String, Node> result = new HashMap<>();
if (uri != null) {
response = client.prepareGet(indexName, docDef.getEntityField(), uri).get();
if (response != null && !response.isSourceEmpty()) {
String entityField = response.getId();
Node entity = NodeFactory.createURI(entityField);
result.put(docDef.getEntityField(), entity);
Map<String, Object> source = response.getSource();
for (String field : docDef.fields()) {
Object fieldResponse = source.get(field);
if (fieldResponse == null) {
//We wont return it.
continue;
} else if (fieldResponse instanceof List<?>) {
//We are storing the values of fields as a List always.
//If there are values stored in the list, then we return the first value,
// else we do not include the field in the returned Map of Field -> Node Mapping
List<?> responseList = (List<?>) fieldResponse;
if (responseList != null && responseList.size() > 0) {
String fieldValue = (String) responseList.get(0);
Node fieldNode = NodeFactoryExtra.createLiteralNode(fieldValue, null, null);
result.put(field, fieldNode);
}
}
}
}
}
return result;
}
use of org.elasticsearch.action.get.GetResponse in project fess by codelibs.
the class FessEsClient method get.
protected <T> T get(final String index, final String type, final String id, final SearchCondition<GetRequestBuilder> condition, final SearchResult<T, GetRequestBuilder, GetResponse> searchResult) {
final long startTime = System.currentTimeMillis();
GetResponse response = null;
final GetRequestBuilder requestBuilder = client.prepareGet(index, type, id);
if (condition.build(requestBuilder)) {
response = requestBuilder.execute().actionGet(ComponentUtil.getFessConfig().getIndexSearchTimeout());
}
final long execTime = System.currentTimeMillis() - startTime;
return searchResult.build(requestBuilder, execTime, OptionalEntity.ofNullable(response, () -> {
}));
}
use of org.elasticsearch.action.get.GetResponse in project play2-elasticsearch by cleverage.
the class IndexService method get.
/**
* Get a reponse for a simple request
* @param indexName
* @param indexType
* @param id
* @return
*/
public static GetResponse get(String indexName, String indexType, String id) {
GetRequestBuilder getRequestBuilder = IndexClient.client.prepareGet(indexName, indexType, id);
GetResponse getResponse = getRequestBuilder.execute().actionGet();
return getResponse;
}
Aggregations