<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/cts.andQuery.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>cts.andQuery</api:function-name><api:suggest>cts.andquery</api:suggest><api:suggest>cts</api:suggest><api:suggest>andquery</api:suggest><api:function-link mode="xquery" fullname="cts:and-query">/apidoc/8.0/cts:and-query.xml</api:function-link><api:function mode="javascript" name="andQuery" type="builtin" lib="cts" category="SearchBuiltins" subcategory="cts:query Constructors" hidden="false" bucket="MarkLogic Built-In Functions" prefix="cts" namespace="http://marklogic.com/cts" fullname="cts.andQuery"><api:summary>
  Returns a query specifying the intersection
  of the matches specified by the sub-queries.
</api:summary><api:params><api:param name="queries" type="cts:query*"><api:param-description>
    A sequence of sub-queries.
  </api:param-description><api:param-name>queries</api:param-name><api:param-type>cts.query[]</api:param-type></api:param><api:param name="options" type="xs:string*" optional="true"><api:param-description>
    Options to this query.  The default is ().
    <p xmlns="http://www.w3.org/1999/xhtml">
      Options include:</p>
      <blockquote xmlns="http://www.w3.org/1999/xhtml"><dl>
        <dt>"ordered"</dt>
        <dd>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.</dd>
        <dt>"unordered"</dt>
        <dd>An unordered and-query, which specifies that the sub-query matches
        can occur in any order. </dd>
     </dl></blockquote>
  </api:param-description><api:param-name>options</api:param-name><api:param-type>String[]</api:param-type></api:param></api:params><api:return>cts.andQuery</api:return><api:usage>
  <p xmlns="http://www.w3.org/1999/xhtml">If the options parameter contains neither "ordered" nor "unordered",
  then the default is "unordered".</p>
  <p xmlns="http://www.w3.org/1999/xhtml">If you specify the empty sequence for the <code>queries</code> parameter
  to <code class="javascript">cts.andQuery</code>, you will get a match for every document in
  the database.  For example, the following query always returns true:</p>
 
 <pre class="javascript" xmlns="http://www.w3.org/1999/xhtml">  cts.contains(fn.collection(), cts.andQuery([]))</pre>
 <p xmlns="http://www.w3.org/1999/xhtml"> In order to match a <code class="javascript">cts.andQuery</code>, the matches
  from each of the specified sub-queries must all occur in the same
  fragment.
 </p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
cts.estimate(
  cts.andQuery([cts.wordQuery("to be or"),
                         cts.wordQuery("or not to be")]));
=&gt; 1
</pre></api:example></api:function></api:function-page>