/** * Update a document in an index given a JSON Patch (see RFC 6902 at * https://tools.ietf.org/html/rfc6902) * @param request The patch request * @param timestamp Optionally a timestamp to set. If not specified then current time is used. * @return The patched document. * @throws OriginalNotFoundException If the original is not found, then it cannot be patched. * @throws IOException If an error occurs while patching. */ default Document patch(RetrieveLatestDao retrieveLatestDao, PatchRequest request , Optional<Long> timestamp ) throws OriginalNotFoundException, IOException { Document d = getPatchedDocument(retrieveLatestDao, request, timestamp); return update(d, Optional.ofNullable(request.getIndex())); }