MNOT
The Mild Not (MNOT) operator is similar to the NOT and MINUS operators. The Mild Not operator returns hits where the the left child is not contained by the right child. Both children can only be TERM or PHRASE nodes.
The semantics can be illustrated with a query of “term1 mnot term1 term2”, where the hits for “term1 term2” will be filtered out. For example:
-
A document with only term1 will be returned, with score unchanged.
-
A document with only term1 term2 will not be returned.
-
A document with term1 term1 term2 will be returned, but the score will be calculated using just the first term1 hit.
The behavior described in the third bullet is different from the behavior of NOT, which does not return this type of document.
The MNOT operator is more specific than the MINUS operator, in that the left child must be contained by the right child. If it is not, the Mild Not operator ignores the right child. Also, for Mild Not, the right child is a true filter, that is, it does not simply subtract the scores of left child and right child.
The MNOT operator has precedence lower than NOT and higher than WITHIN.
Syntax
| Syntax | Description |
|---|---|
| term1 mnot term1 term2 | Returns docs that contain term1 unless it is part of the phrase term1 term2. |
| term1 mnot term2 | Returns all documents that contain term1. It will be the same query as just term1. |
Example for MNOT Operator
The children of the MNOT operator must be a TERM or PHRASE.
SELECT * FROM docs
WHERE CONTAINS(txt, 'term1 mnot term1 term2') >0
Related Topic
“NOT (~)”