对于 CoRB 收集器,我需要在其临时堆栈中找到不是最新的最新文档。例如给定文件:
URI Collections
A.xml A.xml
A.1.xml A.xml
A.2.xml A.xml
B.xml B.xml latest
B.1.xml B.xml
C.xml C.xml
我需要一种快速方法来返回 A.xml
和 C.xml
(但不是 B.xml
)
我想出的最好办法是获取主要 URI 的列表 (A.xml B.xml C.xml
) 并循环它们,然后将集合与 uri 进行比较姓名。但这非常慢。
或者,我可以创建 2 个 corb 进程;通过线程过滤并将其输入到单独的 corb 进程中来构建 URIS_FILE 的第一个进程。然而,这增加了很多复杂性。
是否有任何内置方法可以实现此目的?
最佳答案
您可以使用map intersection查找这些 URI。
两者cts:uris()
和 cts:collections()
可以选择以 map 形式获取结果。因此,如果您查询不在 latest
集合中的 URI 和集合,然后查找交集 - 匹配的 URI 的 URI 和时间集合应该生成这些 URI。您可以使用 map:keys()
您的 CoRB URI 模块将是:
let $not-latest-query := cts:not-query(cts:collection-query("latest"))
let $uris := cts:uris("", "map", $not-latest-query)
let $collections := cts:collections("", "map", $not-latest-query)
let $most-recent-historical := map:keys($uris * $collections)
return (count($most-recent-historical), $most-recent-historical)
关于xquery - 即使已删除,也可在 MarkLogic 时间堆栈中查找最新文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77801190/