@Override public LogEntry getLogEntryByID(long id) { GetResponse ret = esClient.get( new GetRequest(getESIndexName(), ElasticSearchConstants.ENTRY_TYPE, String.valueOf(id))); if (!ret.isExists()) { return null; } try { return new ObjectMapper().readValue(ret.getSourceAsString(), LogEntryImpl.class); } catch (IOException e) { throw new NuxeoException("Unable to read Entry for id " + id, e); } }
/** * Return the ecm:path of an ES document or null if not found. */ String getPathOfDocFromEs(String repository, String docId) { String indexName = getWriteIndexForRepository(repository); GetRequest request = new GetRequest(indexName, DOC_TYPE, docId).fetchSourceContext( new FetchSourceContext(true, new String[] { PATH_FIELD }, null)); if (log.isDebugEnabled()) { log.debug(String.format("Get path of doc: curl -XGET 'http://localhost:9200/%s/%s/%s?fields=%s'", indexName, DOC_TYPE, docId, PATH_FIELD)); } GetResponse ret = esa.getClient().get(request); if (!ret.isExists() || ret.getSource() == null || ret.getSource().get(PATH_FIELD) == null) { // doc not found return null; } return ret.getSource().get(PATH_FIELD).toString(); }