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; } }
if (options.getRouting() != null) builder.setRouting(options.getRouting()); if (options.getParent() != null) builder.setParent(options.getParent()); if (options.isRefresh() != null) builder.setRefresh(options.isRefresh());