xdmp:estimate( $expression as item()*, [$maximum as xs:double?] ) as xs:integer
Returns the number of fragments selected by an expression. This can be used as a fast estimate of the number of items in a sequence.
xdmp:estimate
require that the XPath
expression searched is partially searchable.
A partially searchable XPath expression is one whose first step
is searchable. You can use xdmp:query-trace()
to determine
if a step is searchable. If there are no entries in the
xdmp:query-trace()
output indicating that the first step
is unsearchable
, then the expression is partially searchable
and you can perform an xdmp:estimate
operation on it.
xdmp:estimate(collection()) => 10476
xdmp:estimate(/PLAY/TITLE, 1000) => Returns the number of fragments selected by the XPath expression, up to a maximum of 100.
xdmp:estimate(cts:search(fn:doc(), cts:word-query("merry"))) => Returns an estimate of the number of fragments matched by the search
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.