2012-02-20 109 views
-4

使用下列2级MarkLogic的XQuery序得到预期的结果:MarkLogic搜索的Xquery

  1. ,列出按时间戳的所有文件

    for $x in xdmp:document-properties()//prop:last-modified 
    order by $x descending 
    return <uri>{xdmp:node-uri($x)} {$x}</uri> 
    
  2. 要在文档中从最新的文件

    搜索字符串
    for $a in doc("/contentC:/MLDemo/DataFiles/1234.xml")/*//@System_Name 
    where $a ="Exchange" 
    return $a 
    

我是Marklogic和Xquery的新手。有人可以帮助我将这两个单独的脚本合并为一个脚本。

在此先感谢。

+1

问题说明一点的研究工作。 – 2012-02-20 17:29:40

+0

不清楚预期的结果应该是什么。 – grtjn 2012-02-20 20:43:57

回答

1

假设你没有更改默认的配置,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]

-1
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() 
1

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