diff --git a/vpro-shared-elasticsearch-client/src/main/java/nl/vpro/elasticsearchclient/IndexHelper.java b/vpro-shared-elasticsearch-client/src/main/java/nl/vpro/elasticsearchclient/IndexHelper.java index c7306837d..ebb9044a6 100644 --- a/vpro-shared-elasticsearch-client/src/main/java/nl/vpro/elasticsearchclient/IndexHelper.java +++ b/vpro-shared-elasticsearch-client/src/main/java/nl/vpro/elasticsearchclient/IndexHelper.java @@ -566,10 +566,25 @@ public final ObjectNode post(String path, ObjectNode request, Consumer. } @SafeVarargs - public final ObjectNode postEntity(String path, HttpEntity entity, Consumer... consumers) { + public final ObjectNode put(String path, ObjectNode request, Consumer... consumers) { + return putEntity(path, entity(request), consumers); + } + + public final ObjectNode postEntity(String path, HttpEntity entity, Consumer... consumers) + { + return sendEntity(POST, path, entity, consumers); + } + + public final ObjectNode putEntity(String path, HttpEntity entity, Consumer... consumers) + { + return sendEntity(PUT, path, entity, consumers); + } + + @SafeVarargs + public final ObjectNode sendEntity(String method, String path, HttpEntity entity, Consumer... consumers) { try { - Request req = new Request(POST, path); + Request req = new Request(method, path); req.setEntity(entity); for (Consumer c : consumers) { c.accept(req); @@ -679,7 +694,7 @@ public ObjectNode index(String id, byte[] o) { public ObjectNode index(String id, Object o, Consumer sourceConsumer) { ObjectNode jsonNode = objectMapper.valueToTree(o); sourceConsumer.accept(jsonNode); - return post(indexPath(id), jsonNode); + return put(indexPath(id), jsonNode); }