【问题标题】:cts.estimate showing wrong document countcts.estimate 显示错误的文档计数
【发布时间】:2021-07-24 11:56:03
【问题描述】:

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

cts.estimate(
  cts.trueQuery()
)

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

感谢任何帮助。

【问题讨论】:

  • 您确定内容没有改变(正在添加/删除文档)?相同数量的文档是否始终存在差异?
  • 是的@Mads Hansen 没有文档被添加或删除。
  • @MadsHansen 更新 - 我尝试使用 search:estimate(cts:true-query()) 并通过探索返回与 qconsole 中显示的相同的文档数。

标签: marklogic marklogic-10


【解决方案1】:

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

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

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

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

选项参数中只能指定“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 的属性片段而没有文档。

【讨论】:

  • 谢谢@MadsHansen,您的查询返回了此输出 [1283265, 1283265, 1283262, 3, 0]
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-24
相关资源
最近更新 更多