2

我的要求是获取数据库中可用文档的总数。

cts.estimate(
  cts.trueQuery()
)

当我执行上面的查询时,它返回1283265文档计数,但是当我从 qconsole 探索数据库时,文档计数是1283262所以我不确定这个文档计数不匹配。

任何帮助表示赞赏。

4

1 回答 1

2

您是否可能在数据库中有一些没有文档的 URI?

支持查询控制台探索按钮的代码仅报告估计的文档数量:

let $total-doc := xdmp:estimate(doc())

的默认行为cts.estimate()是搜索any片段。

在 options 参数中只能指定“any”、“document”、“properties”或“locks”之一。如果没有指定“any”、“document”、“properties”或“locks”,并且有 $query 参数,则默认为“document”。如果没有 $query 参数,则默认值为“any”。

运行此查询并验证在为估计指定显式选项时报告的数字:

const estimate_default = cts.estimate(cts.trueQuery());
const estimate_any = cts.estimate(cts.trueQuery(), ["any"]);
const estimate_documents = cts.estimate(cts.trueQuery(), ["document"]);
const estimate_properties = cts.estimate(cts.trueQuery(), ["properties"]);
const estimate_locks = cts.estimate(cts.trueQuery(), ["locks"]);

[estimate_default, estimate_any, estimate_documents, estimate_properties, estimate_locks];

我怀疑数字上的差异是因为某些 URI 没有文档。例如,可以有 URI 的属性片段而没有文档。

于 2021-05-02T13:41:35.407 回答