Loading TOC...


   $queries as cts:query*,
   [$options as xs:string*]
) as cts:and-query


Returns a query specifying the intersection of the matches specified by the sub-queries.

queries A sequence of sub-queries.
options Options to this query. The default is ().

Options include:

An ordered and-query, which specifies that the sub-query matches must occur in the order of the specified sub-queries. For example, if the sub-queries are "cat" and "dog", an ordered query will only match fragments where both "cat" and "dog" occur, and where "cat" comes before "dog" in the fragment.
An unordered and-query, which specifies that the sub-query matches can occur in any order.

Usage Notes

If the options parameter contains neither "ordered" nor "unordered", then the default is "unordered".

If you specify the empty sequence for the queries parameter to cts:and-query, you will get a match for every document in the database. For example, the following query always returns true:

  cts:contains(collection(), cts:and-query(()))

In order to match a cts:and-query, the matches from each of the specified sub-queries must all occur in the same fragment.


      cts:word-query("to be or"),
      cts:word-query("or not to be"))))
  => .. a sequence of 'PLAY' elements which are
  ancestors (or self) of some node whose text content
  contains the phrase 'to be or' AND some node
  whose text content contains the phrase 'or not to be'.
  With high probability this intersection contains only
  one 'PLAY' element, namely,

      "The Tragedy of Hamlet, Prince of Denmark".

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