diff options
Diffstat (limited to 'vespaclient-container-plugin/src/main/java/com/yahoo/document')
3 files changed, 15 insertions, 5 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/OperationHandler.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/OperationHandler.java index 6a811eb5afd..35999df5a6b 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/OperationHandler.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/OperationHandler.java @@ -99,6 +99,10 @@ public interface OperationHandler { void delete(RestUri restUri, String condition, Optional<String> route) throws RestApiException; Optional<String> get(RestUri restUri) throws RestApiException; + + default Optional<String> get(RestUri restUri, Optional<String> fieldSet) throws RestApiException { + return get(restUri); + } /** Called just before this is disposed of */ default void shutdown() {} diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/OperationHandlerImpl.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/OperationHandlerImpl.java index af8650a8e7c..cb4d1b9feed 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/OperationHandlerImpl.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/OperationHandlerImpl.java @@ -295,12 +295,12 @@ public class OperationHandlerImpl implements OperationHandler { } @Override - public Optional<String> get(RestUri restUri) throws RestApiException { + public Optional<String> get(RestUri restUri, Optional<String> fieldSet) throws RestApiException { SyncSession syncSession = syncSessions.alloc(); setRoute(syncSession, Optional.empty()); try { DocumentId id = new DocumentId(restUri.generateFullId()); - final Document document = syncSession.get(id, restUri.getDocumentType() + ":[document]", DocumentProtocol.Priority.NORMAL_1); + final Document document = syncSession.get(id, fieldSet.orElse(restUri.getDocumentType() + ":[document]"), DocumentProtocol.Priority.NORMAL_1); if (document == null) { return Optional.empty(); } @@ -316,6 +316,11 @@ public class OperationHandlerImpl implements OperationHandler { } } + @Override + public Optional<String> get(RestUri restUri) throws RestApiException { + return get(restUri, Optional.empty()); + } + protected BucketSpaceRoute resolveBucketSpaceRoute(Optional<String> wantedCluster, String docType) throws RestApiException { final List<ClusterDef> clusters = clusterEnumerator.enumerateClusters(); ClusterDef clusterDef = resolveClusterDef(wantedCluster, clusters); diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java index a45557859ad..bb9387dc6e0 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java @@ -170,7 +170,7 @@ public class RestApi extends LoggingRequestHandler { try { switch (request.getMethod()) { case GET: // Vespa Visit/Get - return restUri.getDocId().isEmpty() ? handleVisit(restUri, request) : handleGet(restUri); + return restUri.getDocId().isEmpty() ? handleVisit(restUri, request) : handleGet(restUri, request); case POST: // Vespa Put operationHandler.put(restUri, createPutOperation(request, restUri.generateFullId(), condition), route); break; @@ -212,8 +212,9 @@ public class RestApi extends LoggingRequestHandler { return operationUpdate; } - private HttpResponse handleGet(RestUri restUri) throws RestApiException { - final Optional<String> getDocument = operationHandler.get(restUri); + private HttpResponse handleGet(RestUri restUri, HttpRequest request) throws RestApiException { + final Optional<String> fieldSet = requestProperty("fieldSet", request); + final Optional<String> getDocument = operationHandler.get(restUri, fieldSet); final ObjectNode resultNode = mapper.createObjectNode(); if (getDocument.isPresent()) { final JsonNode parseNode; |