Loading TOC...
Matches for xdmp:query-trace have been highlighted. remove

MarkLogic Server 11.0 Product Documentation
xdmp:estimate

xdmp:estimate(
   $expression as item()*,
   [$maximum as xs:double?]
) as xs:integer

Summary

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.

Parameters
expression The expression to estimate. This must be a partially searchable XPath expression or a cts:search() expression.
maximum The maximum value to return. Stop selecting fragments if this number is reached.

Usage Notes

Queries that use 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.

Example

xdmp:estimate(collection())

=> 10476

Example

xdmp:estimate(/PLAY/TITLE, 1000)

=> Returns the number of fragments selected by the XPath expression,
   up to a maximum of 100.

Example

xdmp:estimate(cts:search(fn:doc(), cts:word-query("merry")))

=> Returns an estimate of the number of fragments matched by the search

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.