<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/cts.notQuery.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>cts.notQuery</api:function-name><api:suggest>cts.notquery</api:suggest><api:suggest>cts</api:suggest><api:suggest>notquery</api:suggest><api:function-link mode="xquery" fullname="cts:not-query">/apidoc/8.0/cts:not-query.xml</api:function-link><api:function mode="javascript" name="notQuery" 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.notQuery"><api:summary>
  Returns a query specifying the matches not specified by its sub-query.
</api:summary><api:params><api:param name="query" type="cts:query"><api:param-description>
    A negative query, specifying the search results
    to filter out.
  </api:param-description><api:param-name>query</api:param-name><api:param-type>cts.query</api:param-type></api:param><!-- Do not document: this shouldn't be here and doesn't work
  <apidoc:param name="weight" type="xs:double?" optional="true">
    A weight for this query.
    Higher weights move search results up in the relevance
    order. The default is 1.0. The
    weight should be between 64 and -16.
    Weights greater than 64 will have the same effect as a
    weight of 64.
    Weights less than the absolute value of 0.0625 (between -0.0625 and
    0.0625) are rounded to 0, which means that they do not contribute to the
    score.
  </apidoc:param>
  --></api:params><api:return>cts.notQuery</api:return><api:usage>
  The <code xmlns="http://www.w3.org/1999/xhtml">cts: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: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">$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 the 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">$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: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.search(
    cts.notQuery(
      cts.wordQuery("summer")));
  =&gt; ...  a ValueIterator of documents not containing
          any text node with the word 'summer'.
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
// Insert the following documents:

declareUpdate();
var doc1 = {doc:"Dogs, cats, and pigs"}; 
var doc2 = {doc:"Trees, frogs, and cats"};
var doc3 = {doc:"Dogs, alligators, and wolves"};
xdmp.documentInsert("/cat1.json", doc1);
xdmp.documentInsert("/cat2.json", doc2);
xdmp.documentInsert("/nocat.json", doc3);

******
// Now run the following search:

cts.search(cts.notQuery("cat"));

=&gt;
The document /nocat.json with the following json:

{"doc":"Dogs, alligators, and wolves"}
</pre></api:example></api:function></api:function-page>