
search:estimate( $cts-query as element(), [$options as element(search:options)?] ) as xs:unsignedLong
This function quickly estimates the number of hits a query will return. The result is unfiltered and reflects the index resolution of the search.
| Parameters | |
|---|---|
| cts-query | A cts:query object or serialized cts:query. |
| options | Search API query options with which to customize the search. For details, see Appendix: Query Options Reference in the Search Developer's Guide. |
cts:search expression, or to calling
cts.estimate in Server-Side JavaScript,
except that this function enables you to include Search API
query options in the search.
For example, the following calls are equivalent:
(: XQuery :)
xdmp:estimate(cts:search(fn:doc(),cts:parse("merry")))
search:estimate(search:parse("merry"))
// JavaScript
cts.estimate(cts.wordQuery("merry");
cts.search(search.parse("merry"));
xquery version "1.0-ml";
import module namespace search = "http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
search:estimate(search:parse("merry"))
(: Returns an estimate of the number of fragments matching the
word query produced by search:parse.
:)
xquery version "1.0-ml";
import module namespace search = "http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
search:estimate(cts:word-query("merry"))
(: Returns an estimate of the number of fragments matching the word query. :)