Not Query

edit

Deprecated in 2.1.0.

Use the bool query with must_not clause instead

A query that filters out matched documents using a query. For example:

{
    "bool" : {
        "must" : {
            "term" : { "name.first" : "shay" }
        },
        "filter" : {
            "not" : {
                "range" : {
                    "postDate" : {
                        "from" : "2010-03-01",
                        "to" : "2010-04-01"
                    }
                }
            }
        }
    }
}

Or, in a longer form with a filter element:

{
    "bool" : {
        "must" : {
            "term" : { "name.first" : "shay" }
        },
        "filter" : {
            "not" : {
                "filter" :  {
                    "range" : {
                        "postDate" : {
                            "from" : "2010-03-01",
                            "to" : "2010-04-01"
                        }
                    }
                }
            }
        }
    }
}