【发布时间】:2016-10-02 04:37:57
【问题描述】:
如果我必须在 MarkLogic 中插入一个文档,我如何使用 Java API 指定该文档应该存储在哪个森林中?
这是我将数据写入 MarkLogic 数据库的示例:
// create the client
DatabaseClient client = DatabaseClientFactory.newClient(
props.host, props.port, props.writerUser, props.writerPassword,
props.authType);
// make use of the client connection
TextDocumentManager docMgr = client.newTextDocumentManager();
String docId = "/example/text.txt";
StringHandle handle = new StringHandle();
handle.set("A simple text document");
docMgr.write(docId, handle);
如果我可以通过指定森林来存储文档,那么我还需要获取指定森林的文档。
我认为这是可能的,因为我已经看到在 XQuery 中的特定 forestId 中进行存储和搜索。像这样:
插入特定的森林:
xdmp:document-insert(
$uri as xs:string,$root as node(),
[$permissions as element(sec:permission)*], [$collections as xs:string*],
[$quality as xs:int?], [$forest-ids as xs:unsignedLong*])
as empty-sequence()
搜索特定的森林 -
cts:search(
$expression as node()*, $query as cts:query?,
[$options as (cts:order|xs:string)*], [$quality-weight as xs:double?],
[$forest-ids as xs:unsignedLong*]) as node()*
请让我知道如何在 Java API 中执行此操作。
【问题讨论】:
标签: marklogic marklogic-8