# Add exception/exclusion to must\_not clause in elasticsearch

**URL:** https://discuss.elastic.co/t/add-exception-exclusion-to-must-not-clause-in-elasticsearch/35674
**Category:** Elasticsearch
**Created:** [November 26, 2015, 1:35pm UTC](https://discuss.elastic.co/t/add-exception-exclusion-to-must-not-clause-in-elasticsearch/35674 "2015-11-26T13:35:30Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ekaitzht](https://avatars.discourse-cdn.com/v4/letter/e/a5b964/32.png) [@ekaitzht](https://discuss.elastic.co/u/ekaitzht)
#### Post date: [November 26, 2015, 1:35pm UTC](https://discuss.elastic.co/t/add-exception-exclusion-to-must-not-clause-in-elasticsearch/35674/1 "2015-11-26T13:35:30Z")

</div>

I have this problem in elasticsearch, I would like to filter all products related to a specific brand "Brand1".  
However I would like to have an exception and keep a specific type of product for that brand.  
How can I do that?, for now I have this query which removes all products related to brand1.

```
POST brandindex/product/_search
{  
            "filter":{
                "bool": {
                    "should": [   
                      {"bool": {
                            "must_not":[ 
                             	{"term" : {"brand.raw" : "Brand1"}},  
                            ]
                         }
                      }
                    ]
                }
                
            }
        
    ,
    "size":3000
}  

```

Is it possible to do it without adding a new bool in the should array like the next query?

```
 POST brandindex/product/_search
{  
            "filter":{
                "bool": {
                    "should": [   
                      {"bool": {
                            "must_not":[ 
                             	{"term" : {"brand.raw" : "Brand1"}},  
                            ]
                         }
                      },
					  {"bool": {
                            "must":[ 
                             	{"term" : {"brand.raw" : "Brand1"}},  
							 	{"term" : {"type.raw" : "slippers"}}
                            ]
                         }
                      }
                    ]
                }
                
            }
        
    ,
    "size":3000
}               

```

Thanks

---

<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 5, 2017, 11:35pm UTC](https://discuss.elastic.co/t/add-exception-exclusion-to-must-not-clause-in-elasticsearch/35674/2 "2017-07-05T23:35:35Z")

</div>


