cts:registered-query( $ids as xs:unsignedLong*, [$options as xs:string*], [$weight as xs:double?] ) as cts:registered-query
Returns a query matching fragments specified by previously registered
queries (see cts:register
). If
the database is not empty and a registered query with the specified ID(s)
is not found, then a cts:search
operation with an invalid
cts:registered-query
throws an XDMP-UNREGISTERED exception.
Searches that use registered queries will generate results with different scores than the equivalent searches using non-registered queries. This is because registered queries are treated as a single term in relevance calculations.
If the options parameter does not contain "unfiltered", then an error is returned, as the "unfiltered" option is required.
Registered queries are persisted as a soft state only; they can
become unregistered through an explicit direction (using
cts:deregister
),
as a result of the cache growing too large, or because of a server restart.
Consequently, either your XQuery code or your middleware layer should handle
the case when an XDMP-UNREGISTERED exception occurs (for example, you can
wrap your cts:registered-query
code in a try/catch block
or your Java or .NET code can catch and handle the exception).
Unfiltered queries, including registered queries, do not match in cts:walk or cts:highlight.
cts:search(//function, cts:registered-query(1234567890123456,"unfiltered")) => .. relevance-ordered sequence of 'function' elements in any document that also matches the registered query
(: wrap the registered query in a try/catch :) try { cts:search(fn:doc(),cts:registered-query(995175721241192518,"unfiltered")) } catch ($e) { if ($e/err:code = "XDMP-UNREGISTERED") then ("Retry this query with the following registered query ID: ", cts:register(cts:word-query("hello*world","wildcarded"))) else $e } }