search:resolve-nodes( $query as element(), [$options as element(search:options)?], [$start as xs:unsignedLong?], [$page-length as xs:unsignedLong?] ) as node()*
This function performs the same search as
search:search
, but it takes
a parsed and annotated cts:query
XML node or a
structured search search:query
XML node as
input and returns the actual result nodes from the database.
Parameters | |
---|---|
query | Either a
serialized and annotated cts:query , or
a structured query (search:query ).
You can generate either form of query as the result of a
call to
search:parse .
|
options | Options to define the search
grammar and control the search. See the description for
$options
for the function search:search .
|
start | The index of the first hit to return. The default is 1. |
page-length | The maximum number of hits to return. The default is 10. If the value is 0, no results are returned. |
extract-document-data
option, each returned node contains the data specified by the
extraction, rather than the entire document or fragment.
To obtain a search:response
instead of the matching
nodes, use search:resolve
.
xquery version "1.0-ml"; import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy"; search:resolve-nodes(search:parse("Vannevar Bush"), <options xmlns="http://marklogic.com/appservices/search"> <return-results>false</return-results> <return-facets>true</return-facets> </options>) => ... sequence of document nodes ...
(: structured query example, plain search for "hello" :) xquery version "1.0-ml"; import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy"; let $struct-query := <query xmlns="http://marklogic.com/appservices/search"> <term-query> <text>hello</text> </term-query> </query> return search:resolve-nodes($struct-query) => returns the nodes that match a query for "hello"