# Logical not tests drop target/tests/querytestnot; create target/tests/querytestnot; add {"_id":"1", "bar": "fox"}; "1" add {"_id":"2", "bar": "quick fox"}; "2" add {"_id":"3", "bar": "quick brown fox"}; "3" add {"_id":"4", "bar": ["fox"]}; "4" add {"_id":"5", "bar": ["quick fox"]}; "5" add {"_id":"6", "bar": ["quick brown fox"]}; "6" add {"_id":"7", "baz": ["fox"]}; "7" add {"_id":"8", "baz": ["quick","fox"]}; "8" add {"_id":"9", "baz": ["quick","brown","fox"]}; "9" add {"_id":"10", "baz": [["quick"],["brown"],["fox"]]}; "10" add {"_id":"11", "baz": [["brown"],["fox"]]}; "11" add {"_id":"12", "baz": [["fox"]]}; "12" find {(bar: ~="fox" || bar: ~="brown") && (bar: !~="quick")} return ._id ; [ "1" ] find {(bar: ~="fox" || bar: ~="brown") && !(bar: ~="quick")} return ._id ; [ "1" ] find {bar: ~="fox" || bar: ~="brown"} && !{bar: ~="quick"} return ._id ; [ "1" ] find {bar: [(~="fox" || ~="brown") && !~="quick"]} return ._id ; [ "4" ] find {bar: [(~="fox" || ~="brown") && !(~="quick")]} return ._id ; [ "4" ] find {bar: [~="fox" || ~="brown"] && bar: ![~="quick"]} return ._id ; [ "4" ] find {baz: [(~="fox" || ~="brown") && !~="quick"]} return ._id ; [ "7", "8", "9" ] find {baz: [(~="fox" || ~="brown") && !(~="quick")]} return ._id ; [ "7", "8", "9" ] find {baz: [~="fox" || ~="brown"] && baz: ![~="quick"]} return ._id ; [ "7" ] find {baz: [~="fox" || ~="brown"] && baz: [!~="fox"]} return ._id ; [ "8", "9" ] find {baz: [~="fox" || ~="brown"] && baz: [!="fox"]} return ._id ; [ "8", "9" ] # not a field that doesn't exist. find {baz: [~="fox" || ~="brown"] && missing: ![~="fox"]} return ._id ; [ "7", "8", "9" ] find {baz: [[~="brown"]] || baz: [[!~="fox"]]} return ._id ; [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11" ] find {baz: [[~="brown"]] && baz: [[!~="fox"]]} return ._id ; [ "10", "11" ] find {_id: == "12" && baz: [[!="fox"]]} return ._id ; [] # Test for unallowable expressions find !{baz: [~="fox"]} return ._id ; Parse error: query cannot be made up of only logical not. Must have at least one match clause not negated. find !{baz: ~="fox"} && !{baz: =="foo"} return ._id ; Parse error: Logical not ("!") is nested inside of another logical not. This is not allowed. find {foo: =="bar"} && !{baz: !~="fox"} return ._id ; Parse error: Logical not ("!") is nested inside of another logical not. This is not allowed.