我们需要使用 XQuery 生成报告,其中需要详细信息,例如数据库大小和数据库文档计数(文档总数)。
我们有下面的 XQuery 代码,我们可以从中获取数据库名称和数据库大小,但我们还希望包括 AdminUI 中的数据库文档计数。
for $db-id in xdmp:databases()
let $db-name := xdmp:database-name($db-id)
let $db-size :=
fn:sum(
for $f-id in xdmp:database-forests($db-id)
let $f-status := xdmp:forest-status($f-id)
let $space := $f-status/forest:device-space
let $f-name := $f-status/forest:forest-name
let $f-size :=
fn:sum(
for $stand in $f-status/forest:stands/forest:stand
let $stand-size := $stand/forest:disk-size/fn:data(.)
return $space
)
return $f-size
)
order by $db-size descending
return $db-name || " = " || $db-size
就像是
return $db-name || " = " || $db-size || "=" || $db-count
使用下面,我们可以获取单个数据库中的文档计数(无论在 QC 下拉列表中选择什么),但我需要在单个脚本中为所有数据库运行以下命令。
xdmp:estimate(doc())
对此有任何帮助或建议吗?我在这里先向您的帮助表示感谢。