使用 MarkLogic REST API,当我将 Accept
设置为 multipart/mixed
时,我会看到以下格式的响应:
--BOUNDARY
Content-Type: application/xml
Content-Disposition: attachment; filename="/hcp/458.xml"; category=content; format=xml
Content-Length: 412
<?xml version="1.0" encoding="UTF-8"?>
<hcp xmlns="http://schemas.com">
<id>458</id>
<tenantId>2</tenantId>
<firstName>Hoongoong</firstName>
<middleName/>
<lastName>Tangyy</lastName>
</hcp>
--BOUNDARY
Content-Type: application/xml
Content-Disposition: attachment; filename="/hcp/2.xml"; category=content; format=xml
Content-Length: 409
<?xml version="1.0" encoding="UTF-8"?>
<hcp xmlns="http://schemas.com">
<id>2</id>
<tenantId>3</tenantId>
<firstName>Hoong</firstName>
<middleName>F</middleName>
<lastName>Tang</lastName>
</hcp>
--BOUNDARY
有没有办法通过一些调整或应用转换将结果显示为单个文档(包含文档作为子元素)而不是由边界分隔的多个文档?
<results>
<hcp>
<id>458</id>
.....
</hcp>
<hcp>
<id>2</id>
......
</hcp>
</results>
最佳答案
您可以使用 REST API
执行搜索,将 Accept header 设置为 application/xml
。
指定 all 的 extract-document-data
选项以获取整个文档。
http://docs.marklogic.com/guide/rest-dev/appendixb#id_18313
如果您只需要列出特定文档,则可以使用文档查询:
http://docs.marklogic.com/guide/search-dev/structured-query#id_27172
您还可以在服务器上转换搜索响应:
http://docs.marklogic.com/guide/rest-dev/search#id_94556
希望有帮助,
关于marklogic - 如何使用 MarkLogic 的 REST API 将多个文档转换为单个文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30733248/