本文整理了Java中org.elasticsearch.client.RestHighLevelClient.get
方法的一些代码示例,展示了RestHighLevelClient.get
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RestHighLevelClient.get
方法的具体详情如下:
包路径:org.elasticsearch.client.RestHighLevelClient
类名称:RestHighLevelClient
方法名:get
[英]Retrieves a document by id using the Get API. See Get API on elastic.co
[中]使用Get API按id检索文档。见Get API on elastic.co
代码示例来源:origin: apache/incubator-gobblin
@Override
public GetResponse get(GetRequest getRequest)
throws IOException {
return highLevelClient.get(getRequest);
}
代码示例来源:origin: Netflix/conductor
@Override
public String get(String workflowInstanceId, String fieldToGet) {
GetRequest request = new GetRequest(indexName, WORKFLOW_DOC_TYPE, workflowInstanceId);
GetResponse response;
try {
response = elasticSearchClient.get(request);
} catch (IOException e) {
logger.error("Unable to get Workflow: {} from ElasticSearch index: {}", workflowInstanceId, indexName, e);
return null;
}
if (response.isExists()){
Map<String, Object> sourceAsMap = response.getSourceAsMap();
if (sourceAsMap.containsKey(fieldToGet)){
return sourceAsMap.get(fieldToGet).toString();
}
}
logger.debug("Unable to find Workflow: {} in ElasticSearch index: {}.", workflowInstanceId, indexName);
return null;
}
代码示例来源:origin: apache/nifi
@Override
public Map<String, Object> get(String index, String type, String id) throws IOException {
GetRequest get = new GetRequest(index, type, id);
GetResponse resp = highLevelClient.get(get, new Header[]{});
return resp.getSource();
}
代码示例来源:origin: spring-projects/spring-data-elasticsearch
@Override
public <T> T queryForObject(GetQuery query, Class<T> clazz, GetResultMapper mapper) {
ElasticsearchPersistentEntity<T> persistentEntity = getPersistentEntityFor(clazz);
GetRequest request = new GetRequest(persistentEntity.getIndexName(), persistentEntity.getIndexType(),
query.getId());
GetResponse response;
try {
response = client.get(request);
T entity = mapper.mapResult(response, clazz);
return entity;
} catch (IOException e) {
throw new ElasticsearchException("Error while getting for request: " + request.toString(), e);
}
}
代码示例来源:origin: dadoonet/fscrawler
@Override
public ESSearchHit get(String index, String id) throws IOException {
GetRequest request = new GetRequest(index, id);
GetResponse response = client.get(request, RequestOptions.DEFAULT);
ESSearchHit hit = new ESSearchHit();
hit.setIndex(response.getIndex());
hit.setId(response.getId());
hit.setVersion(response.getVersion());
hit.setSourceAsMap(response.getSourceAsMap());
return hit;
}
代码示例来源:origin: dadoonet/fscrawler
@Override
public ESSearchHit get(String index, String id) throws IOException {
GetRequest request = new GetRequest(index, getDefaultTypeName(), id);
GetResponse response = client.get(request);
ESSearchHit hit = new ESSearchHit();
hit.setIndex(response.getIndex());
hit.setId(response.getId());
hit.setVersion(response.getVersion());
hit.setSourceAsMap(response.getSourceAsMap());
return hit;
}
代码示例来源:origin: dadoonet/fscrawler
@Override
public ESSearchHit get(String index, String id) throws IOException {
GetRequest request = new GetRequest(index, getDefaultTypeName(), id);
GetResponse response = client.get(request, RequestOptions.DEFAULT);
ESSearchHit hit = new ESSearchHit();
hit.setIndex(response.getIndex());
hit.setId(response.getId());
hit.setVersion(response.getVersion());
hit.setSourceAsMap(response.getSourceAsMap());
return hit;
}
代码示例来源:origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-core
@Override
public GetResponse get(GetRequest request) {
try {
return client.get(request, RequestOptions.DEFAULT);
} catch (IOException e) {
throw new NuxeoException(e);
}
}
代码示例来源:origin: org.apache.nifi/nifi-elasticsearch-client-service
@Override
public Map<String, Object> get(String index, String type, String id) throws IOException {
GetRequest get = new GetRequest(index, type, id);
GetResponse resp = highLevelClient.get(get, new Header[]{});
return resp.getSource();
}
代码示例来源:origin: dqeasycloud/easy-cloud
public GetResponse get(String indexName, String type, String id) throws IOException {
try {
GetRequest getRequest = new GetRequest(
indexName,
type,
id);
GetResponse getResponse = client.get(getRequest);
return getResponse;
} catch (ElasticsearchException exception) {
if (exception.status() == RestStatus.NOT_FOUND) {
}
}
return null;
}
代码示例来源:origin: com.wuyushuo/vplus-data
@Override
public GetResponse selectIndex(String index, String type, String id) throws Exception {
GetRequest request = new GetRequest(index, type, id);
log.debug(request.toString());
return client().get(request);
}
代码示例来源:origin: eea/eea.elasticsearch.river.rdf
private String getLastUpdate() {
String res = "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
//TODO: status update
GetRequest getRequest = new GetRequest(this.statusIndex, "last_update", riverName );
//TODO: move to async ?
try {
GetResponse getResponse = client.get(getRequest);
if(!getResponse.isSourceEmpty()){
Long updated = (Long) getResponse.getSource().get("updated_at");
res = sdf.format(updated);
}
} catch (IOException e) {
logger.error("Could not get last_update, use Date(0)", e);
res = sdf.format(new Date(0));
}
return res;
}
代码示例来源:origin: DigitalPebble/storm-crawler
public void run() {
if (esClient == null) {
try {
esClient = ElasticSearchConnection.getClient(stormConf,
"config");
} catch (Exception e) {
LOG.error("Exception while creating ES connection", e);
}
}
if (esClient != null) {
LOG.info("Reloading json resources from ES");
try {
GetResponse response = esClient.get(new GetRequest(
"config", "config", resource.getResourceFile()));
resource.loadJSONResources(new ByteArrayInputStream(
response.getSourceAsBytes()));
} catch (Exception e) {
LOG.error("Can't load config from ES", e.getMessage());
}
}
}
}, 0, refreshRate * 1000);
代码示例来源:origin: DigitalPebble/storm-crawler
public void run() {
if (esClient == null) {
try {
esClient = ElasticSearchConnection.getClient(stormConf,
"config");
} catch (Exception e) {
LOG.error("Exception while creating ES connection", e);
}
}
if (esClient != null) {
LOG.info("Reloading json resources from ES");
try {
GetResponse response = esClient.get(new GetRequest(
"config", "config", resource.getResourceFile()));
resource.loadJSONResources(new ByteArrayInputStream(
response.getSourceAsBytes()));
} catch (Exception e) {
LOG.error("Can't load config from ES", e.getMessage());
}
}
}
}, 0, refreshRate * 1000);
代码示例来源:origin: eea/eea.elasticsearch.river.rdf
private void setClusterStatus(String status) {
String statusIndex = indexName + "_status";
boolean indexing = false;
GetRequest getRequest = new GetRequest(statusIndex, "last_update" , riverName);
try {
GetResponse getResponse = client.get(getRequest);
if(getResponse.getSource().get("status") == "indexing"){
indexing = true;
}
} catch (IOException e) {
//e.printStackTrace();
}
if(!indexing){
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("status", status);
UpdateRequest request = new UpdateRequest( statusIndex, "last_update", riverName)
.doc(jsonMap);
try {
UpdateResponse updateResponse = client.update(request);
logger.info("Updating index {} status to: indexing", riverName);
} catch (IOException e) {
logger.error("{}", e);
}
} else {
}
}
代码示例来源:origin: mnemonic-no/act-platform
/**
* Retrieve an indexed Fact by its UUID. Returns NULL if Fact cannot be fetched from ElasticSearch.
*
* @param id UUID of indexed Fact
* @return Indexed Fact or NULL if not available
*/
public FactDocument getFact(UUID id) {
if (id == null) return null;
GetResponse response;
try {
GetRequest request = new GetRequest(INDEX_NAME, TYPE_NAME, id.toString());
response = clientFactory.getHighLevelClient().get(request);
} catch (IOException ex) {
throw logAndExit(ex, String.format("Could not perform request to fetch Fact with id = %s.", id));
}
if (response.isExists()) {
LOGGER.info("Successfully fetched Fact with id = %s.", id);
return decodeFactDocument(id, response.getSourceAsBytes());
} else {
// Fact isn't indexed in ElasticSearch, log warning and return null.
LOGGER.warning("Could not fetch Fact with id = %s. Fact not indexed?", id);
return null;
}
}
代码示例来源:origin: org.apache.camel/camel-elasticsearch-rest
} else if (operation == ElasticsearchOperation.GetById) {
GetRequest getRequest = message.getBody(GetRequest.class);
message.setBody(restHighLevelClient.get(getRequest, RequestOptions.DEFAULT));
} else if (operation == ElasticsearchOperation.Bulk) {
BulkRequest bulkRequest = message.getBody(BulkRequest.class);
代码示例来源:origin: eea/eea.elasticsearch.river.rdf
private boolean checkRiverNotExists() {
GetRequest getRequest = new GetRequest(indexer.getRIVER_INDEX(), "river", riverName);
try {
GetResponse getResponse = client.get(getRequest);
if (getResponse.isExists()) {
return false;
} else {
logger.error("River doesn't exist anymore");
logger.error("INDEXING CANCELLED");
//TODO: update global-search_status ? or remove indexed cluster?
this.close();
return true;
}
} catch (IOException e) {
e.printStackTrace();
logger.error("River doesn't exist anymore");
logger.error("INDEXING CANCELLED");
this.close();
return true;
}
}
代码示例来源:origin: fr.pilato.elasticsearch.crawler/fscrawler-elasticsearch-client-v5
@Override
public ESSearchHit get(String index, String type, String id) throws IOException {
GetRequest request = new GetRequest(index, type, id);
GetResponse response = client.get(request);
ESSearchHit hit = new ESSearchHit();
hit.setIndex(response.getIndex());
hit.setId(response.getId());
hit.setVersion(response.getVersion());
hit.setSourceAsMap(response.getSourceAsMap());
return hit;
}
内容来源于网络,如有侵权,请联系作者删除!