private UpdateRequestBuilder buildUpdateRequestForReferencedFields(Entity parent, Entity child, boolean updateParent) { UpdateRequestBuilder urb = index.getClient() .prepareUpdate() .setIndex(index.getIndex(getLocalClass())) .setType(getLocalType()) .setRetryOnConflict(3) .setId(child.getId()); EntityDescriptor descriptor = index.getDescriptor(getLocalClass()); if (descriptor.hasRouting()) { Object routingKey = descriptor.getProperty(descriptor.getRouting()).writeToSource(child); if (Strings.isEmpty(routingKey)) { IndexAccess.LOG.WARN("Updating an entity of type %s (%s) without routing information!", child.getClass().getName(), child.getId()); } else { urb.setRouting(String.valueOf(routingKey)); } } Script script = computeUpdateScript(parent, updateParent); urb.setScript(script); if (IndexAccess.LOG.isFINE()) { IndexAccess.LOG.FINE("UPDATE: %s.%s: %s", index.getIndex(getLocalClass()), getLocalType(), script.toString()); } return urb; }
if (options.getRouting() != null) builder.setRouting(options.getRouting()); if (options.getParent() != null) builder.setParent(options.getParent()); if (options.isRefresh() != null) builder.setRefresh(options.isRefresh());