# Exclude particular fields from \[all\_field\] searches

**URL:** <https://discuss.elastic.co/t/exclude-particular-fields-from-all-field-searches/76837>\
**Category:** Elasticsearch\
**Created:** [February 28, 2017, 5:17pm UTC](https://discuss.elastic.co/t/exclude-particular-fields-from-all-field-searches/76837 "2017-02-28T17:17:04Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![niaz](https://avatars.discourse-cdn.com/v4/letter/n/d9b06d/32.png) [@niaz](https://discuss.elastic.co/u/niaz)\
**Post date:** [March 2, 2017, 10:49am UTC](https://discuss.elastic.co/t/exclude-particular-fields-from-all-field-searches/76837/6 "2017-03-02T10:49:16Z")

</div>

Hello Mark,

I have executed following code and it seems under the hood \_all field is used. That means, the feature of elasticsearch 5.1 can not be used where we can disable the \_all field completely.

1. 

DELETE test\_index

1. 

PUT test\_index  
{  
"mappings": {  
"user": {  
"include\_in\_all": false,  
"properties": {  
"title": { "type": "text", "include\_in\_all": true },  
"name": { "type": "text", "include\_in\_all": true },  
"age": { "type": "integer" },  
"tags": { "type": "text", "include\_in\_all": false }  
}  
}  
}  
}

1. 

POST test\_index/\_bulk  
{ "index" : { "\_type" : "user", "\_id" : "1" } }  
{ "name" : "niaz", "title" : "test", "age" : 40, "tags" : "toyota, bmw" }  
{ "index" : { "\_type" : "user", "\_id" : "2" } }  
{ "name" : "john", "title" : "toyota", "age" : 30 }  
{ "index" : { "\_type" : "user", "\_id" : "3" } }  
{ "name" : "bell", "title" : "mercedes", "age" : 35 }  
{ "index" : { "\_type" : "user", "\_id" : "4" } }  
{ "name" : "akram", "title" : "bmw", "age" : 42 }

1. 

GET test\_index/\_search  
{  
"query": {  
"query\_string": {  
"query": "toyota"  
}  
}  
}

The query under 4 results ONE document, CORRECT as we had disabled "include\_in\_all" from our "tags" field.

Now update the mapping for "tags" field like below:

1. 

PUT test\_index/\_mapping/user  
{  
"properties": {  
"tags" : { "type": "text", "include\_in\_all": true }  
}  
}

Execute the query from point 4 again and it will return again 1 document. That means, the "include\_in\_all" cannot be changed dynamically. Instead the documents that are already indexed will not be affected when this setting is changed from false to true or vice versa.

1. 

I post one more document using below command.  
POST test\_index/\_bulk  
{ "index" : { "\_type" : "user", "\_id" : "5" } }  
{ "name" : "Mark Walkom", "title" : "elastic", "age" : 35, "tags" : "toyota, tesla" }

Execute the query under (4) again and this time 2 documents will be returned as the "tags" field from (6) is indexed.

My point: I want to use the feature of elastic search 5.1 where \_all field can be disabled by default and all fields are indexed only once. At the time of search, when no default field is provided a user configured \_all field should be used for searching. Please accept this feature request for next version of elastic search.

Thanks  
Niaz

---

_[View the full topic](https://discuss.elastic.co/t/exclude-particular-fields-from-all-field-searches/76837)._
