GetResponse response = client.prepareGet(configIndex, configType, configName) .setPreference("_local").execute().actionGet();
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.getVersionType() != null) builder.setVersionType(options.getVersionType()); if (options.getPreference() != null) builder.setPreference(options.getPreference()); if (!options.getFields().isEmpty()) { builder.setFields(options.getFields().toArray(new String[options.getFields().size()]));