cts:parse( $query as xs:string, [$bindings as map:map?] ) as cts:query
Parses a query string
Parameters | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
query | The query string. For details, see Creating a Query From Search Text With cts:parse in the Search Developer's Guide. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bindings |
Bindings for mapping x:y parts of the query string.
The map key can be either a simple string with no embedded spaces or
punctuation or the empty string. The empty string defines the parsing
of untagged words. For details, see
Binding a Tag to a Reference, Field, or Query Generator in the Search Developer's Guide.
The map value for the label can be:
|
xquery version "1.0-ml"; cts:search(fn:doc(), cts:parse("cat AND dog")) ==> all documents containing the words "dog" and "cat"
xquery version "1.0-ml"; cts:parse("cat NEAR/5 dog AND mouse") ==> cts:and-query( (cts:near-query( (cts:word-query("cat", ("lang=en"), 1), cts:word-query("dog", ("lang=en"), 1)), 5, ("unordered"), 1), cts:word-query("mouse", ("lang=en"), 1)), ("unordered"))
xquery version "1.0-ml"; let $bindings := let $map := map:map() return ( map:put($map, "title", cts:element-reference(xs:QName("title"))), map:put($map, "by", "person-field"), map:put($map, "cat", function($operator, $values, $options) { cts:collection-query($values) }), map:put($map, "", function($operator, $values, $options) { cts:json-property-word-query('desc', $values, 'case-sensitive', 2)}), $map ) return cts:parse("title:grapes by:steinbeck cat:classics california", $bindings) ==> cts:and-query( (cts:element-word-query(fn:QName("","title"), "grapes", ("lang=en"), 1), cts:field-word-query("by", "steinbeck", ("lang=en"), 1), cts:collection-query("classics"), cts:json-property-word-query("desc", "california", ("case-sensitive","lang=en"), 2)), ("unordered"))