@Override public <T> T mapResult(GetResponse response, Class<T> clazz) { T result = mapEntity(response.getSourceAsString(), clazz); if (result != null) { setPersistentEntityId(result, response.getId(), clazz); setPersistentEntityVersion(result, response.getVersion(), clazz); } return result; }
@Override public <T> LinkedList<T> mapResults(MultiGetResponse responses, Class<T> clazz) { LinkedList<T> list = new LinkedList<>(); for (MultiGetItemResponse response : responses.getResponses()) { if (!response.isFailed() && response.getResponse().isExists()) { T result = mapEntity(response.getResponse().getSourceAsString(), clazz); setPersistentEntityId(result, response.getResponse().getId(), clazz); setPersistentEntityVersion(result, response.getResponse().getVersion(), clazz); list.add(result); } } return list; }
private Tuple<Long, Settings> toSettings(GetResponse singleGetResponse) { final BytesReference ref = singleGetResponse.getSourceAsBytesRef(); final String id = singleGetResponse.getId(); final long version = singleGetResponse.getVersion();
private static GetResult getResponseToGetResult(GetResponse response) { return new GetResult(response.getIndex(), response.getType(), response.getId(), response.getVersion(), response.isExists(), response.getSourceAsBytesRef(), response.getFields()); }
private Tuple<Long, Settings> toSettings(GetResponse singleGetResponse) { final BytesReference ref = singleGetResponse.getSourceAsBytesRef(); final String type = singleGetResponse.getType(); final long version = singleGetResponse.getVersion(); if (ref == null || ref.length() == 0) { log.error("Empty or null byte reference for {}", type);
/** * The version of the doc. */ public long getVersion() { return getResponse.getVersion(); }
@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; }
@Override public long version() { return this.getResponse.getVersion(); }
@Override public long getVersion() { return this.getResponse.getVersion(); }
@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; }
@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; }
@Override public void onResponse(GetResponse getResponse) { JsonObject source = (getResponse.isExists() ? new JsonObject(getResponse.getSourceAsString()) : null); JsonObject reply = new JsonObject() .put(CONST_INDEX, getResponse.getIndex()) .put(CONST_TYPE, getResponse.getType()) .put(CONST_ID, getResponse.getId()) .put(CONST_VERSION, getResponse.getVersion()) .put(CONST_SOURCE, source); resultHandler.handle(Future.succeededFuture(reply)); }
/** * Returns a Document representing the specified document ID (combination of resource and context), or * null when no such Document exists yet. */ @Override protected SearchDocument getDocument(String id) throws IOException { GetResponse response = client.prepareGet(indexName, documentType, id).execute().actionGet(); if (response.isExists()) { return new ElasticsearchDocument(response.getId(), response.getType(), response.getIndex(), response.getVersion(), response.getSource(), geoContextMapper); } // no such Document return null; }
private Tuple<Long, Settings> toSettings(GetResponse singleGetResponse) { final BytesReference ref = singleGetResponse.getSourceAsBytesRef(); final String type = singleGetResponse.getType(); final long version = singleGetResponse.getVersion(); if (ref == null || ref.length() == 0) { log.error("Empty or null byte reference for {}", type);
private Tuple<Long, Settings> toSettings(GetResponse singleGetResponse) { final BytesReference ref = singleGetResponse.getSourceAsBytesRef(); final String id = singleGetResponse.getId(); final long version = singleGetResponse.getVersion();
@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; }
private <E extends Entity> E executeFind(@Nullable String index, @Nullable String routing, @Nonnull Class<E> clazz, String id, EntityDescriptor descriptor) throws Exception { GetResponse res = getClient().prepareGet(index, descriptor.getType(), id) .setPreference("_primary") .setRouting(routing) .execute() .actionGet(); if (!res.isExists()) { if (LOG.isFINE()) { LOG.FINE("FIND: %s.%s: NOT FOUND", index, descriptor.getType()); } return null; } else { E entity = clazz.newInstance(); entity.initSourceTracing(); entity.setId(res.getId()); entity.setVersion(res.getVersion()); descriptor.readSource(entity, res.getSource()); if (LOG.isFINE()) { LOG.FINE("FIND: %s.%s: FOUND: %s", index, descriptor.getType(), Strings.join(res.getSource())); } return entity; } }