2012-02-20 104 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