我试图获得附加到特定数据库的所有森林的总大小.
使用下面的代码我得到了所有单独森林的大小,但坚持如何实现解决方案:
for $db-id in xdmp:databases()
let $db-name := xdmp:database-name($db-id)
for $forests in xdmp:forest-status(xdmp:database-forests(xdmp:database($db-name)))
let $space := $forests//forest:device-space
let $f_name := $forests//forest:forest-name
for $stand in $forests//forest:stands
let $f_size := fn:sum($stand/forest:stand/forest:disk-size)
Run Code Online (Sandbox Code Playgroud) 我试图将此XML文件转换为JSON但无法取得任何成功.我的XML中有两个子元素,但它只返回最后一个.如何以JSON格式获取两个记录?
XML
<Carousel>
<Video>
<Title>1</Title>
<Abstract>3</Abstract>
<FileName type="custom" mediatype="image">D</FileName>
<HasAccess>4</HasAccess>
</Video>
<Video>
<Title>1</Title>
<Abstract>2</Abstract>
<FileName type="custom" mediatype="image">D</FileName>
<HasAccess>3</HasAccess>
</Video>
</Carousel>
Run Code Online (Sandbox Code Playgroud)
XQUERY:
import module namespace json = "http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy";
let $custom := let $config := json:config("custom")
return
(
map:put( $config, "whitespace", "ignore" ),
$config
)
let $XML := $XMLFile (: XML content :)
return json:transform-to-json($XML,$custom)
Run Code Online (Sandbox Code Playgroud)
当前输出:
{"Carousel":{"Video":{"Title":"1", "Abstract":"2", "FileName":{"type":"custom", "mediatype":"image", "_value":"D"}, "HasAccess":"3"}}}
Run Code Online (Sandbox Code Playgroud)
我也尝试使用默认的"基本"JSON设置,json:transform-to-json($XML)
但得到了错误
XML Element not in expected namespace [http://marklogic.com/xdmp/json/basic] (json:INVALIDELEM): Carousel
Run Code Online (Sandbox Code Playgroud)
它仅在"完全"模式下工作,但它正在添加一些JSON格式的额外信息,如_attribute等,这在我的输出JSON中是不需要的.
请帮助我或者说明为什么它没有以JSON格式返回完整的输出.
我有以下代码:
1)
for $song in cts:search(fn:doc(), "night")
return $song/ts:top-song/ts:title/text()
Run Code Online (Sandbox Code Playgroud)
2)
cts:search(fn:doc(), "night")/ts:top-song/ts:title/text()
Run Code Online (Sandbox Code Playgroud)
cts:search根据相关性返回文档。两种代码都以不同顺序返回结果。哪个将返回具有正确相关性的结果,为什么?
在我的 MarkLogic 数据库中,我们有符合 URI 格式的文档,其方式如下:
/documents/12345.xml
/documents/12-abc.xml
/documents/abc-123-def.xml
/12345.xml
Run Code Online (Sandbox Code Playgroud)
我想在 cts:uri-match 中运行正则表达式来仅选择那些符合格式的 uri
> /documents/{integer-values}.xml
Run Code Online (Sandbox Code Playgroud)
请建议如何使这项工作有效。数据库中有数百万个文档,我只想选择符合上述格式的uri,将对这些文档运行CORB进程进行转换。我不想获取所有 URI,然后运行 fn:matches 查询来完成这项工作。
我正在使用 ML 9.0 版并开始使用 TDE(模板驱动提取)。我有很多 XML 文件(每个 50 kb 的 3500 个 xml 文件)并将它们成功加载到 ML。我成功创建了一些基本模板(TDE)。但是当我到达同一元素组的重复组时,视图返回一个空结果。唯一的方法是将上下文设置在我不想要的较低级别,因为我无法从更高的节点中选择元素。
下面的 XML 定义显示了 XML 文件的示例:
<scope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<item>
<transaction>
<type>CI</type>
<sscc>00000379471900000025</sscc>
<location>4260210630688</location>
<device>VISTALINK.004</device>
<date>2017-04-25</date>
<time>02:15:33</time>
<gmtOffset>+02:00</gmtOffset>
<actorId>155081</actorId>
</transaction>
<order>
<orderNumber>3794719</orderNumber>
</order>
<load>
<rti>
<ean>8714548186004</ean>
<grai>8003087145481860040019877322</grai>
<column>2</column>
<size>
<width>1900</width>
<height>95</height>
<depth>0</depth>
</size>
<position>
<x>2062,48707520218</x>
<y>2015,24337520512</y>
<z>0</z>
</position>
</rti>
<rti>
<ean>8714548106002</ean>
<grai>8003087145481060020016434653</grai>
<column>0</column>
<size>
<width>1900</width>
<height>95</height>
<depth>0</depth>
</size>
<position/>
</rti>
<rti>
<ean>8714548186004</ean>
<grai>8003087145481860040012803719</grai>
<column>2</column>
<size>
<width>1900</width>
<height>95</height>
<depth>0</depth>
</size>
<position>
<x>2064,20629390666</x>
<y>2124,57539157396</y>
<z>0</z>
</position>
</rti>
<rti>...</rti> …
Run Code Online (Sandbox Code Playgroud) 我是这个MarkLogic数据库的新手,直到现在我们使用它来使用XQuery对XML文档进行crud操作.
现在需求发生了一些变化,需要将json数据和文档(可能是xml/json)存储到不同的集合中,并使用Java api + spring boot执行crud操作
以下3个示例集合包含类似于mongo db的json数据
Employee Collection
-------------------
empid,
`emp id json`
Address Collecion
-----------------------
empid,
`address details json`
Documents collection
-----------------
empid ,
`document (xml/json )`
Run Code Online (Sandbox Code Playgroud)
这在MarkLogic DB中是否可行?如果是,请帮助我找到解决方法.
并且需要使用搜索API来使用Marklogic + Spring启动来过滤上述3个集合