# How to exclude the particular type in search

**URL:** <https://discuss.elastic.co/t/how-to-exclude-the-particular-type-in-search/6116>\
**Category:** Elasticsearch\
**Created:** [December 10, 2011, 6:50am UTC](https://discuss.elastic.co/t/how-to-exclude-the-particular-type-in-search/6116 "2011-12-10T06:50:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [December 10, 2011, 6:50am UTC](https://discuss.elastic.co/t/how-to-exclude-the-particular-type-in-search/6116/1 "2011-12-10T06:50:30Z")

</div>

Hi there,  
I do fave a case, where i do have almost 50 types in one  
index, i want all those types to be searchable in the search, but not some  
particular two types, so i think including all that 48 types will not be a  
good idea.so can anyone give me the alternative to exclude those 2 types  
from the search.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 10, 2011, 4:31pm UTC](https://discuss.elastic.co/t/how-to-exclude-the-particular-type-in-search/6116/2 "2011-12-10T16:31:30Z")

</div>

There isn't an option to exclude types, just include them. The types filter  
can potentially have excludes aspect to it, you can open an issue, but for  
now, you will have to list the full 48.

On Sat, Dec 10, 2011 at 8:50 AM, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in)wrote:

> Hi there,  
> I do fave a case, where i do have almost 50 types in one  
> index, i want all those types to be searchable in the search, but not some  
> particular two types, so i think including all that 48 types will not be a  
> good idea.so can anyone give me the alternative to exclude those 2 types  
> from the search.

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [December 12, 2011, 10:10am UTC](https://discuss.elastic.co/t/how-to-exclude-the-particular-type-in-search/6116/3 "2011-12-12T10:10:13Z")

</div>

On Sat, 2011-12-10 at 18:31 +0200, Shay Banon wrote:

> There isn't an option to exclude types, just include them. The types  
> filter can potentially have excludes aspect to it, you can open an  
> issue, but for now, you will have to list the full 48.

Wouldn't this work?

curl -XGET '[http://127.0.0.1:9200/\_all/\_search?pretty=1](http://127.0.0.1:9200/_all/_search?pretty=1)' -d '  
{  
"query" : {  
"filtered" : {  
"filter" : {  
"not" : {  
"or" : [  
{  
"type" : {  
"value" : "type\_1"  
}  
},  
{  
"term" : {  
"\_type" : "type\_2"  
}  
}  
]  
}  
},  
"query" : {  
"text" : {  
"foo" : "bar"  
}  
}  
}  
}  
}  
'

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 12, 2011, 1:15pm UTC](https://discuss.elastic.co/t/how-to-exclude-the-particular-type-in-search/6116/4 "2011-12-12T13:15:05Z")

</div>

Yes 🙂

On Mon, Dec 12, 2011 at 12:10 PM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:

> On Sat, 2011-12-10 at 18:31 +0200, Shay Banon wrote:
> 
> > There isn't an option to exclude types, just include them. The types  
> > filter can potentially have excludes aspect to it, you can open an  
> > issue, but for now, you will have to list the full 48.
> 
> Wouldn't this work?
> 
> curl -XGET '[http://127.0.0.1:9200/\_all/\_search?pretty=1](http://127.0.0.1:9200/_all/_search?pretty=1)' -d '  
> {  
> "query" : {  
> "filtered" : {  
> "filter" : {  
> "not" : {  
> "or" : [  
> {  
> "type" : {  
> "value" : "type\_1"  
> }  
> },  
> {  
> "term" : {  
> "\_type" : "type\_2"  
> }  
> }  
> ]  
> }  
> },  
> "query" : {  
> "text" : {  
> "foo" : "bar"  
> }  
> }  
> }  
> }  
> }  
> '

---

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [December 16, 2011, 4:53am UTC](https://discuss.elastic.co/t/how-to-exclude-the-particular-type-in-search/6116/5 "2011-12-16T04:53:20Z")

</div>

Thanks so much, hope it will help.

---

<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, 3:45am UTC](https://discuss.elastic.co/t/how-to-exclude-the-particular-type-in-search/6116/6 "2017-07-06T03:45:16Z")

</div>


