Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

andNot (Structured Query)

isubiker edited this page Nov 11, 2011 · 2 revisions

Handy way to return documents that match one set of query constructors but not the other.

The follow query will return documents where the author key equals "Noam Chomsky" but the title doesn't contain "Manufacturing Consent":

{"andNot": {
    "positive": {
        "key": "author"
        "equals": "Noam Chomsky"
    },
    "negative": {
        "key": "title"
        "contains": "Manufacturing Consent"
    }
}}

<andNot>
    <positive>
        <constraint>
            <key>author</equals>
            <equals>Noam Chomsky</equals>
        </constraint>
    </positive>
    <negative>
        <constraint>
            <key>title</key>
            <contains>Manufacturing Consent</contains>
        </constraint>
    </negative>
</andNot>
Clone this wiki locally