使用以下2个MarkLogic Xquery以获得预期结果:
-
按时间戳列出所有文档
for $x in xdmp:document-properties()//prop:last-modified order by $x descending return <uri>{xdmp:node-uri($x)} {$x}</uri>
-
从最后一个文件中搜索文档中的字符串
for $a in doc("/contentC:/MLDemo/DataFiles/1234.xml")/*//@System_Name where $a ="Exchange" return $a
我是Marklogic和Xquery的新手。有人能帮我把这两个单独的剧本合并成一个剧本吗。
提前谢谢。
假设您没有更改默认配置,prop:last-modified
应该会有所帮助。
请参阅https://docs.marklogic.com/guide/app-dev/properties以了解有关属性的更多信息。
请注意,/*//@System_Name where $a ="Exchange"
在大型数据库中的性能不佳。指定一个元素并使用XPath谓词。尝试更像/a/b/c[@d eq $value]
的东西,或者如果您有多个元素/a/b/(c|d|e)[@z eq $value]
let $URI:=<uris>{
for $x in xdmp:document-properties()//prop:last-modified
order by $x descending
return <uri>{xdmp:base-uri($x)}</uri>
}</uris>
for $a in $URI//uri
let $doc:= doc($a)/*//@System_Name
where $a ="Exchange"
return $a
这个问题有很多答案。
我建议您学习基本的XQuery语法。例如,尝试http://www.amazon.com/XQuery-Priscilla-Walmsley/dp/0596006349
for $a in doc("/contentC:/MLDemo/DataFiles/1234.xml")/*//@System_Name
return
if($a eq "Exchange") then
for $x in xdmp:document-properties()//prop:last-modified
order by $x descending
return <uri>{xdmp:node-uri($x)} {$x}</uri>
else ()