简体   繁体   English

如何使用 Marklogic 为 TDE 做集合

[英]How to do collections-not for TDE with Marklogic

I am looking to how to implement the collections-not for Marklogic TDE.我正在寻找如何实现集合,而不是 Marklogic TDE。

The equivalent one for the CTS query is CTS 查询的等效项是

cts:not-query(cts:collection-query("archived"))

According to TDE documentation , it only supports AND , OR collections.根据TDE 文档,它只支持ANDOR集合。 I am looking for NOT collections with TDE schema.我正在寻找具有 TDE 架构的NOT集合。

EDIT: I changed the sample from: '.. = "include"..' to '... != "exclude"...' They both work.编辑:我将样本从: '.. = "include"..'更改为'... != "exclude"...'它们都有效。 However, for the context of the question, not-equal makes more sense in an example.但是,对于问题的上下文,不等于在示例中更有意义。

As odd as it seems, the feature that you are asking for is not available.看起来很奇怪,您要求的功能不可用。 However, there is a way to make use of the context that can help you.但是,有一种方法可以利用上下文来帮助您。 First of all, it is still good to set a collection or collection scope so that we minimize the sample set to analyze the context path.首先,设置一个集合或者集合范围还是不错的,这样我们就可以最小化样本集来分析上下文路径。

The approach is to use xPath and xQuery on the context as a filter.该方法是在上下文中使用 xPath 和 xQuery 作为过滤器。

Below is a working sample for Query Console.以下是查询控制台的工作示例。 Please not the ';'请不要使用';' in the code as it is a multi-statement sample.在代码中,因为它是一个多语句示例。

xquery version "1.0-ml";

let $_ := xdmp:document-insert("/llamas/Jalliue.xml", <llama><name>Jalliue</name></llama>, map:new()=>map:with("collections", ("llama", "include")))
let $_ := xdmp:document-insert("/llamas/Sven.xml", <llama><name>Sven</name></llama>, map:new()=>map:with("collections", ("llama", "exclude")))
return ();



let $docs := (fn:doc("/llamas/Jalliue.xml"), fn:doc("/llamas/Sven.xml"))

let $template := 
<template xmlns="http://marklogic.com/xdmp/tde">
  <description>llama list</description>
  <context>/llama[xdmp:node-collections(.) != "exclude"]</context>
  <rows>
    <row>
      <schema-name>llama</schema-name>
      <view-name>list</view-name>
      <columns>
        <column>
          <name>name</name>
          <scalar-type>string</scalar-type>
          <val>name</val>
        </column>
      </columns>
    </row>
  </rows>
</template>

return tde:node-data-extract($docs, $template)

The result shows that both documents were considered, but only the one with the collection "include" is parsed.结果表明,这两个文档都被考虑了,但只解析了包含“include”集合的文档。

{
  "/llamas/Jalliue.xml": [
    {
      "row": {
      "schema": "llama", 
      "view": "list", 
      "data": {
        "rownum": "1", 
        "name": "Jalliue"
        }
      }
    }
  ], 
  "/llamas/Sven.xml": []
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM