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(cts:search(fn:doc(), cts:word-query("merry"))) => Returns an estimate of the number of fragments matched by the search
xdmp:estimate(cts:search(fn:doc(), cts:word-query("merry"))) => Returns an estimate of the number of fragments matched by the search