diff --git a/apix_server/src/main/java/whelk/apixserver/ApixSearchServlet.java b/apix_server/src/main/java/whelk/apixserver/ApixSearchServlet.java index 0b151e143b..0ff5bdc50e 100644 --- a/apix_server/src/main/java/whelk/apixserver/ApixSearchServlet.java +++ b/apix_server/src/main/java/whelk/apixserver/ApixSearchServlet.java @@ -27,14 +27,9 @@ public void doGet2(HttpServletRequest request, HttpServletResponse response) thr { Set resultingIDs = search(request); - Map resultingDocumentsMap = Utils.s_whelk.bulkLoad(new ArrayList<>(resultingIDs)); - List resultingDocuments = new ArrayList<>(); - for (String key : resultingDocumentsMap.keySet()) - resultingDocuments.add(resultingDocumentsMap.get(key)); - boolean includeHold = request.getParameter("x-holdings") != null && request.getParameter("x-holdings").equalsIgnoreCase("true"); - Utils.send200Response(response, Xml.formatApixSearchResponse(resultingDocuments, includeHold, request.getParameterMap())); + Utils.send200Response(response, Xml.formatApixSearchResponse(new ArrayList<>(resultingIDs), includeHold, request.getParameterMap())); } private Set search(HttpServletRequest request) diff --git a/apix_server/src/main/java/whelk/apixserver/Xml.java b/apix_server/src/main/java/whelk/apixserver/Xml.java index c6df12ffee..5e24e46dc7 100644 --- a/apix_server/src/main/java/whelk/apixserver/Xml.java +++ b/apix_server/src/main/java/whelk/apixserver/Xml.java @@ -113,7 +113,7 @@ public static String formatApixGetRecordResponse(String marcXmlString, return docToString(xmlDoc); } - public static String formatApixSearchResponse(List resultingDocuments, + public static String formatApixSearchResponse(List resultingIDs, boolean includeHold, Map parameterMap) throws TransformerException, IOException, SAXException { @@ -143,8 +143,9 @@ public static String formatApixSearchResponse(List resultingDocu Element records = xmlDoc.createElement("records"); result.appendChild(records); - for (whelk.Document document : resultingDocuments) + for (String id : resultingIDs) { + whelk.Document document = Utils.s_whelk.loadEmbellished(id); Element record = xmlDoc.createElement("record"); records.appendChild(record);