MarkLogic Server 11.0 Product Documentation
cts:and-not-query

cts:and-not-query(
   $positive-query as cts:query,
   $negative-query as cts:query
) as cts:and-not-query

Summary

Returns a query specifying the set difference of the matches specified by two sub-queries.

Parameters
positive-query A positive query, specifying the search results filtered in.
negative-query A negative query, specifying the search results to filter out.

Usage Notes

This query construct 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:and-not-query is only guaranteed to be accurate if the negative query is accurate from its index resolution (that is, if the unfiltered results of the negative query are accurate. The accuracy of the index resolution depends on many factors such as the query, whether 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 $negative-query parameter has false positive matches, the negation of the query can miss matches (have false negative matches). In these cases, searches with cts:and-not-query can miss results, even if those searches are filtered.

Example

  cts:search(//PLAY,
    cts:and-not-query(
      cts:word-query("summer"),
      cts:word-query("glorious")))
  => .. sequence of 'PLAY' elements containing some
  text node with the word 'summer' BUT NOT containing
  any text node with the word 'glorious'.  This sequence
  may be (in fact is) non-empty, but certainly does not
  contain the PLAY element with:

    PLAY/TITLE =
      "The Tragedy of King Richard the Second"

  since this play contains both 'glorious' and 'summer'.
Powered by MarkLogic Server | Terms of Use | Privacy Policy