2015-05-05 02:27:52 -04:00
|
|
|
[[query-dsl-not-query]]
|
2015-06-03 19:59:22 -04:00
|
|
|
=== Not Query
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2015-05-05 02:27:52 -04:00
|
|
|
A query that filters out matched documents using a query. For example:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2015-09-11 04:35:56 -04:00
|
|
|
"bool" : {
|
|
|
|
"must" : {
|
2013-08-28 19:24:34 -04:00
|
|
|
"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:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2015-09-11 04:35:56 -04:00
|
|
|
"bool" : {
|
|
|
|
"must" : {
|
2013-08-28 19:24:34 -04:00
|
|
|
"term" : { "name.first" : "shay" }
|
|
|
|
},
|
|
|
|
"filter" : {
|
|
|
|
"not" : {
|
|
|
|
"filter" : {
|
|
|
|
"range" : {
|
|
|
|
"postDate" : {
|
|
|
|
"from" : "2010-03-01",
|
|
|
|
"to" : "2010-04-01"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|