
cts.notQuery( query as cts.query ) as cts.notQuery
Returns a query specifying the matches not specified by its sub-query.
| Parameters | |
|---|---|
| query | A negative query, specifying the search results to filter out. | 
cts:not-query 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
  cts:not-query 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 $query parameter to
  cts:not-query 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
  cts:search 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 $query parameter has false-positive matches,
  the negation of the query can miss matches (have false negative matches).
  In these cases,
  searches with cts:not-query can miss results, even if those
  searches are filtered.
  cts.search(
    cts.notQuery(
      cts.wordQuery("summer")));
  => ...  a Sequence of documents not containing
          any text node with the word 'summer'.
// Insert the following documents:
declareUpdate();
const doc1 = {doc:"Dogs, cats, and pigs"};
const doc2 = {doc:"Trees, frogs, and cats"};
const 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"));
=>
The document /nocat.json with the following json:
{"doc":"Dogs, alligators, and wolves"}