0

我正在从 Marklogic Server 的 UI 中插入一些 xml 文档,同时在列表中显示它们。我想按顺序显示文件。首先插入的文档应该排在列表的首位。第二个文件应该排在第二位,依此类推。但是 Marklogic 是随机显示它们,没有任何顺序。

4

2 回答 2

2

使用 MarkLogic Server 时,插入顺序不会保留或保留。如果您希望保留文档的插入顺序,则数据或数据的属性将需要一些值,服务器可以在该值上执行“order by”子句。

for $doc in fn:doc()
order by $doc//some-aspect-of-the-xml-structure
return
$doc

这些文档在“无共享”架构中确实彼此独立。这有助于 MarkLogic 比一些“行”在“表”中共享成员资格和排序的关系数据库方法运行得更快,因此无法有效地进行集群。

于 2012-06-20T18:13:22.100 回答
0

您可以按上次更新的数据排序文档:

(:If uri lexicone is enabled, else you can iterate by fn:collection():)
for $uri in cts:uris((), "document") 
let $updated-date := xdmp:document-get-properties($uri, fn:QName("http://marklogic.com/cpf", "last-updated"))
order by $updated-date/text()
return $uri

还有另一种方法,不使用 uri 词典:

for $doc in fn:collection()
let $uri := xdmp:node-uri($doc)
let $updated-date := xdmp:document-get-properties($uri, fn:QName("http://marklogic.com/cpf", "last-updated"))
order by $updated-date/text()
return $uri
于 2012-06-26T10:54:31.017 回答