Skip to content

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