【问题标题】:Specify forest while inserting/fetching the document in marklogic在 marklogic 中插入/获取文档时指定森林
【发布时间】: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


    【解决方案1】:

    今天,这不能通过 Java 客户端 API 获得。它将在 MarkLogic 9 中可用。如果您想在 MarkLogic 9 的早期访问版本中试用它,您可以加入early access program。在试用此功能后,我们很乐意听到您的反馈。

    在 MarkLogic 9 中,您可以通过将 forestName 指定给 DatabaseClientFactory 来做到这一点:

    DatabaseClient client = DatabaseClientFactory.newClient(
        props.host, props.port, props.writerUser, props.writerPassword,
        props.authType, props.forestName);
    

    然后写入的文档将被写入该林中,搜索将仅在该林中匹配。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-08
      • 1970-01-01
      • 1970-01-01
      • 2021-03-09
      相关资源
      最近更新 更多