Loading TOC...

xdmp:exists

xdmp:exists(
   $expression as item()*
) as xs:boolean

Summary

Returns true if any fragment is selected by an expression, false if no fragments are selected. This can be used as a fast existence check.

Parameters
$expression The expression to check. This must be a partially searchable XPath expression or a cts:search() expression.

Usage Notes

Queries that use xdmp:exists 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:exists operation on it.

Calling xdmp:exists on an expression is the same as calling xdmp:estimate on the expression with a maximum of 1. For example, the following are equivalent:

     xdmp:exists(cts:search(collection(), "foo"))

       is equivalent to:

     xs:boolean(xdmp:estimate(cts:search(collection(), "foo"), 1)) 

Example

xdmp:exists(collection())
=> true

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

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.