# NotFilter dude

**URL:** https://discuss.elastic.co/t/notfilter-dude/20248
**Category:** Elasticsearch
**Created:** [October 14, 2014, 6:26pm UTC](https://discuss.elastic.co/t/notfilter-dude/20248 "2014-10-14T18:26:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Waldemar\_Neto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waldemar_neto/32/1190_2.png) [@Waldemar\_Neto](https://discuss.elastic.co/u/Waldemar_Neto)
#### Post date: [October 14, 2014, 6:26pm UTC](https://discuss.elastic.co/t/notfilter-dude/20248/1 "2014-10-14T18:26:17Z")

</div>

Hello all!  
ia have a criteria with _AND_ , _OR_ and _NOT_ operator, but the _NOT_ is a  
single Filter, what is the best way to set multiples _NOT's_?

see my query with _AND_

my _AND_ i need _NOT_ 😃

{  
"highlight": {  
"fields": {  
"\*": {  
"fragment\_size": 150,  
"number\_of\_fragments": 1,  
"pre\_tags": [  
"**"  
],  
"post\_tags": [  
"**"  
]  
}  
}  
},  
"facets": {  
"documents": {  
"terms": {  
"field": "primary\_field",  
"size": 5  
}  
}  
},  
"fields": [  
"Document.id",  
"Document.name",  
"Document.updated",  
"DocumentTag.name",  
"Document.approval\_number",  
"Document.approval\_number\_us",  
"Document.approval\_number\_jp",  
"Version.status",  
"Document.rate",  
"Document.last\_status"  
],  
"sort": [  
"\_type"  
],  
"size": 100000,  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"and": {  
"filters": [  
{  
"terms": {  
"Product.id": [  
"6"  
]  
}  
},  
{  
"terms": {  
"Version.jp": [  
true  
]  
}  
},  
{  
"terms": {  
"Version.jp": [  
true  
]  
}  
},  
{  
"terms": {  
"Document.last\_status": [  
"4"  
]  
}  
}  
]  
}  
}  
}  
}  
}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d9d34e14-7d3c-41a5-b3ad-a33ccbd79d45%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d9d34e14-7d3c-41a5-b3ad-a33ccbd79d45%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Itamar\_Syn\_Hershko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itamar_syn_hershko/32/725_2.png) [@Itamar\_Syn\_Hershko](https://discuss.elastic.co/u/Itamar_Syn_Hershko)
#### Post date: [October 15, 2014, 7:55am UTC](https://discuss.elastic.co/t/notfilter-dude/20248/2 "2014-10-15T07:55:45Z")

</div>

See

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

You should probably switch to a bool and a should clause before instead of  
an and filter

--

Itamar Syn-Hershko  
[http://code972.com](http://code972.com) | @synhershko [https://twitter.com/synhershko](https://twitter.com/synhershko)  
Freelance Developer & Consultant  
Author of RavenDB in Action [http://manning.com/synhershko/](http://manning.com/synhershko/)

On Tue, Oct 14, 2014 at 9:26 PM, Waldemar Neto [waldemarnt@gmail.com](mailto:waldemarnt@gmail.com) wrote:

> Hello all!  
> ia have a criteria with _AND_ , _OR_ and _NOT_ operator, but the _NOT_ is  
> a single Filter, what is the best way to set multiples _NOT's_?
> 
> see my query with _AND_
> 
> my _AND_ i need _NOT_ 😃
> 
> {  
> "highlight": {  
> "fields": {  
> "\*": {  
> "fragment\_size": 150,  
> "number\_of\_fragments": 1,  
> "pre\_tags": [  
> "**"  
> ],  
> "post\_tags": [  
> "**"  
> ]  
> }  
> }  
> },  
> "facets": {  
> "documents": {  
> "terms": {  
> "field": "primary\_field",  
> "size": 5  
> }  
> }  
> },  
> "fields": [  
> "Document.id",  
> "Document.name",  
> "Document.updated",  
> "DocumentTag.name",  
> "Document.approval\_number",  
> "Document.approval\_number\_us",  
> "Document.approval\_number\_jp",  
> "Version.status",  
> "Document.rate",  
> "Document.last\_status"  
> ],  
> "sort": [  
> "\_type"  
> ],  
> "size": 100000,  
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "and": {  
> "filters": [  
> {  
> "terms": {  
> "Product.id": [  
> "6"  
> ]  
> }  
> },  
> {  
> "terms": {  
> "Version.jp": [  
> true  
> ]  
> }  
> },  
> {  
> "terms": {  
> "Version.jp": [  
> true  
> ]  
> }  
> },  
> {  
> "terms": {  
> "Document.last\_status": [  
> "4"  
> ]  
> }  
> }  
> ]  
> }  
> }  
> }  
> }  
> }
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/d9d34e14-7d3c-41a5-b3ad-a33ccbd79d45%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d9d34e14-7d3c-41a5-b3ad-a33ccbd79d45%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/d9d34e14-7d3c-41a5-b3ad-a33ccbd79d45%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/d9d34e14-7d3c-41a5-b3ad-a33ccbd79d45%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAHTr4ZvhhpLcLojKEk0%2Bw\_sx%3DFeMkOnvSbiK-aWYeH7ByD1WWg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHTr4ZvhhpLcLojKEk0%2Bw_sx%3DFeMkOnvSbiK-aWYeH7ByD1WWg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Waldemar\_Neto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waldemar_neto/32/1190_2.png) [@Waldemar\_Neto](https://discuss.elastic.co/u/Waldemar_Neto)
#### Post date: [October 16, 2014, 5:44pm UTC](https://discuss.elastic.co/t/notfilter-dude/20248/3 "2014-10-16T17:44:27Z")

</div>

i used the boolfilter with must\_not 😃 and works fine

Em terça-feira, 14 de outubro de 2014 15h26min17s UTC-3, Waldemar Neto  
escreveu:

> Hello all!  
> ia have a criteria with _AND_ , _OR_ and _NOT_ operator, but the _NOT_ is  
> a single Filter, what is the best way to set multiples _NOT's_?
> 
> see my query with _AND_
> 
> my _AND_ i need _NOT_ 😃
> 
> {  
> "highlight": {  
> "fields": {  
> "\*": {  
> "fragment\_size": 150,  
> "number\_of\_fragments": 1,  
> "pre\_tags": [  
> "**"  
> ],  
> "post\_tags": [  
> "**"  
> ]  
> }  
> }  
> },  
> "facets": {  
> "documents": {  
> "terms": {  
> "field": "primary\_field",  
> "size": 5  
> }  
> }  
> },  
> "fields": [  
> "Document.id",  
> "Document.name",  
> "Document.updated",  
> "DocumentTag.name",  
> "Document.approval\_number",  
> "Document.approval\_number\_us",  
> "Document.approval\_number\_jp",  
> "Version.status",  
> "Document.rate",  
> "Document.last\_status"  
> ],  
> "sort": [  
> "\_type"  
> ],  
> "size": 100000,  
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "and": {  
> "filters": [  
> {  
> "terms": {  
> "Product.id": [  
> "6"  
> ]  
> }  
> },  
> {  
> "terms": {  
> "Version.jp": [  
> true  
> ]  
> }  
> },  
> {  
> "terms": {  
> "Version.jp": [  
> true  
> ]  
> }  
> },  
> {  
> "terms": {  
> "Document.last\_status": [  
> "4"  
> ]  
> }  
> }  
> ]  
> }  
> }  
> }  
> }  
> }

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/dea0c612-c1a1-4c0d-9fda-ad70a0cbfb0c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/dea0c612-c1a1-4c0d-9fda-ad70a0cbfb0c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 12:55am UTC](https://discuss.elastic.co/t/notfilter-dude/20248/4 "2017-07-06T00:55:42Z")

</div>


