cts.andNotQuery( $positive-query as cts.query, $negative-query as cts.query ) as cts.andNotQuery
Returns a query specifying the set difference of the matches specified by two sub-queries.
|$positive-query||A positive query, specifying the search results filtered in.|
|$negative-query||A negative query, specifying the search results to filter out.|
cts:and-not-queryconstructor 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-queryis 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
cts:not-queryare 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
cts:searchspecifies 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-queryparameter has false positive matches, the negation of the query can miss matches (have false negative matches). In these cases, searches with
cts:and-not-querycan miss results, even if those searches are filtered.
cts.estimate( cts.andNotQuery( cts.wordQuery("summer"), cts.wordQuery("glorious"))) => .. 12 Shakespeare Plays contain some text node with the word 'summer' BUT NOT the word 'glorious'.