search.resolveNodes( query as Node, [options as element(search.options)?], [start as (Number|String)?], [page-length as (Number|String)?] ) as Sequence
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
.
const search = require('/MarkLogic/appservices/search/search'); search.resolveNodes(search.parse('Vannevar Bush'), fn.head(xdmp.unquote('<options xmlns="http://marklogic.com/appservices/search">' + '<return-results>false</return-results>' + '<return-facets>true</return-facets>' + '</options>')).root); // ==> // ... sequence of document nodes ...
// Structured query example, plain search for "hello" const search = require('/MarkLogic/appservices/search/search'); const structQuery = fn.head(xdmp.unquote('<query xmlns="http://marklogic.com/appservices/search">' + '<term-query>' + '<text>hello</text>' + '</term-query>' + '</query>')).root; search.resolveNodes(structQuery); // Returns the nodes that match a query for "hello"