如何使用MarkLogic的REST API将多个文档转换为单个文档? [英] How to transform multiple documents into a single document using MarkLogic's REST API?
问题描述
使用MarkLogic REST API,当我将Accept
设置为multipart/mixed
时,会看到以下格式的响应:
Using MarkLogic REST API, when I set Accept
to multipart/mixed
I see the response in the format:
--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
是否可以通过某种方式进行调整或应用转换以将结果显示为单个文档(包含作为子元素的文档),而不是由边界分隔的多个文档?
Is there a way via some tweak or applying transformation to display the result as a single document (containing documents as child element) instead of multiple documents separated by boundary?
<results>
<hcp>
<id>458</id>
.....
</hcp>
<hcp>
<id>2</id>
......
</hcp>
</results>
推荐答案
您可以使用REST API
执行搜索,将Accept标头设置为application/xml
.
You can execute a search with the REST API
, setting the Accept header to application/xml
.
指定全部的extract-document-data
选项以获取整个文档.
Specify an extract-document-data
option of all to get the entire documents.
http://docs.marklogic.com/guide/rest-dev/appendixb#id_18313
如果您只需要列出特定文档,则可以使用文档查询:
You can use a document-query if you just need to list specific documents:
http://docs.marklogic.com/guide/search- dev/structured-query#id_27172
您还可以在服务器上转换搜索响应:
You can also transform the search response on the server:
http://docs.marklogic.com/guide/rest-dev/search#id_94556
希望有帮助,
这篇关于如何使用MarkLogic的REST API将多个文档转换为单个文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!