<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/cts.andNotQuery.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>cts.andNotQuery</api:function-name><api:suggest>cts.andnotquery</api:suggest><api:suggest>cts</api:suggest><api:suggest>andnotquery</api:suggest><api:function-link mode="xquery" fullname="cts:and-not-query">/apidoc/8.0/cts:and-not-query.xml</api:function-link><api:function mode="javascript" name="andNotQuery" 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.andNotQuery"><api:summary>
  Returns a query specifying the set difference of
  the matches specified by two sub-queries.
</api:summary><api:params><api:param name="positive-query" type="cts:query"><api:param-description>
    A positive query, specifying the search results
    filtered in.
  </api:param-description><api:param-name>positive-query</api:param-name><api:param-type>cts.query</api:param-type></api:param><api:param name="negative-query" type="cts:query"><api:param-description>
    A negative query, specifying the search results
    to filter out.
  </api:param-description><api:param-name>negative-query</api:param-name><api:param-type>cts.query</api:param-type></api:param></api:params><api:return>cts.andNotQuery</api:return><api:usage>
  The <code xmlns="http://www.w3.org/1999/xhtml">cts:and-not-query</code> constructor is fragment-based, so
  it returns true only if the specified query does not produce a match
  anywhere in a fragment.  Therefore, a search using
  <code xmlns="http://www.w3.org/1999/xhtml">cts:and-not-query</code> is only guaranteed to be accurate if the
  underlying query that is being negated is accurate from its index
  resolution (that is,
  if the unfiltered results of the <code xmlns="http://www.w3.org/1999/xhtml">$negative-query</code> parameter to
  <code xmlns="http://www.w3.org/1999/xhtml">cts:not-query</code> are accurate).  The accuracy of the index
  resolution depends on many factors such as the query, if you search
  at a fragment root (that is, if the first parameter of
  <code xmlns="http://www.w3.org/1999/xhtml">cts:search</code> specifies an XPath that resolves to a fragment root),
  the index options enabled on the database, the search options,
  and other factors.
  In cases where the <code xmlns="http://www.w3.org/1999/xhtml">$negative-query</code> parameter has false
  positive matches,
  the negation of the query can miss matches (have false negative matches).
  In these cases,
  searches with <code xmlns="http://www.w3.org/1999/xhtml">cts:and-not-query</code> can miss results, even if those
  searches are filtered.
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  cts.estimate(
    cts.andNotQuery(
      cts.wordQuery("summer"),
      cts.wordQuery("glorious")))
  =&gt; .. 12 Shakespeare Plays contain some text node with the word 
  'summer' BUT NOT the word 'glorious'.  
</pre></api:example></api:function></api:function-page>