Loading TOC...


   $query as String,
   [$bindings as Object?]
) as cts.query


Parses a query string

$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:

A reference to the tag in the query corresponds to a query against the indicated index, which constructs a query.
Reference Operator Query
cts:element-reference ":" cts:element-word-query
cts:element-reference "=" cts:element-value-query
cts:element-attribute-reference ":" cts:element-atrribute-word-query
cts:element-attribute-reference "=" cts:element-attribute-value-query
cts:json-property-reference ":" cts:json-property-word-query
cts:json-property-reference "=" cts:json-property-value-query
cts:field-reference ":" cts:field-word-query
cts:field-reference "=" cts:field-value-query
geospatial reference ":" geospatial query, parameter parsed as a region
geospatial reference "=" or eq geospatial query, parameter parsed as a region
geospatial reference other operator error
cts:uri-reference ":" cts:document-query
cts:uri-reference "=" cts:document-query
cts:collection-reference ":" cts:collection-query
cts:collection-reference "=" cts:collection-query
cts:path-reference ":" cts:word-query (no path word-query)
cts:path-reference "=" cts:path-range-query with operator "=" (no path value-query)
any eq range-query with operator "="
any ne range-query with operator "!="
any lt range-query with operator "<"
any le range-query with operator "<="
any ge range-query with operator ">="
any gt range-query with operator ">"
function ($operator as xs:string, $values as xs:string*, $options as xs:string*) as cts:query?
A reference to the tag in the query calls the function to produce a query.
A reference to the tag in the query corresponds to a field query against the named field.

See Also


cts.search(cts.parse('cat AND dog'))

==> all documents containing the words "dog" and "cat"


cts.parse('cat NEAR/5 dog AND mouse')


  [cts.nearQuery([cts.wordQuery("cat", ["lang=en"], 1), 
   cts.wordQuery("dog", ["lang=en"], 1)], 5, ["unordered"], 1), 
   cts.wordQuery("mouse", ["lang=en"], 1) ], 


// Using bindings
var bindings = {
  title: cts.elementReference('title'),
  by: 'person-field',
  cat: function(operator, values, options) {
    return cts.collectionQuery(values); },
  '': function(operator, values, options) {
    return cts.jsonPropertyWordQuery('desc', values, ['case-sensitive'], 2); }
cts.parse('title:grapes by:steinbeck cat:classics california', bindings)


  [cts.elementWordQuery(fn.QName("","title"), "grapes", ["lang=en"], 1), 
   cts.fieldWordQuery("by", "steinbeck", ["lang=en"], 1), 
   cts.jsonPropertyWordQuery("desc", "california", 
      ["case-sensitive","lang=en"], 2)],

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


The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • Can you provide an example of how to specify bindings to get an elementRangeQuery? How do you write a binding confirming to as listed in the cts.reference table? any eq range-query with operator "="
    • Thanks Kim & David. I found I was able to get the range query by specifying a cts.elementReference binding and using EQ in the query string as shown in the link Kim provided. The reason I was struggling with this is because the documentation above has lower-case eq as the operator. And David - I know you recommended I ask these questions on StackOverflow, but thought asking these questions here would help improve the documentation.
      • It does; it's just that not as many people will see your question here, so you won't always get a timely response. Glad we were able to get you going this time.
    • var bindings = { name: function(operator, values, options) { return cts.elementRangeQuery(xs.QName('name'), operator, values); } }; cts.parse('name=bob', bindings); See http://docs.marklogic.com/guide/search-dev/cts_query#id_43355 for more details.
    • You create a binding to a reference to your element range index. If you read the topic on creating bindings in the Search Developer's Guide, there is an range query example. http://docs.marklogic.com/guide/search-dev/cts_query#id_58102