# Disable \_source field store or enable compression for it

**URL:** <https://discuss.elastic.co/t/disable--source-field-store-or-enable-compression-for-it/4524>\
**Category:** Elasticsearch\
**Created:** [June 1, 2011, 8:20pm UTC](https://discuss.elastic.co/t/disable--source-field-store-or-enable-compression-for-it/4524 "2011-06-01T20:20:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Slava\_G](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@Slava\_G](https://discuss.elastic.co/u/Slava_G)\
**Post date:** [June 1, 2011, 8:20pm UTC](https://discuss.elastic.co/t/disable--source-field-store-or-enable-compression-for-it/4524/1 "2011-06-01T20:20:54Z")

</div>

Hi,  
I wanted to disable storing \_source field and also to not make one of  
the fields not analyzable, this is the code:  
Client client = node.client();

```
		 XContentBuilder data = jsonBuilder().startObject()
         .startObject("properties")
                 .startObject("bdate")
                         .field("type", "string")
                         .field("index", "not_analyzed")
                         .field("store", "yes")
                 .endObject()
                 .startObject("_source")
                         .field("enabled", false)
                 .endObject()
                 .endObject()
         .endObject();

		client.admin().indices().create(new

```

CreateIndexRequest("test").mapping("cont", data));  
IndexResponse indexRes = client.prepareIndex("test", "cont", "1")  
.setSource(jsonBuilder()  
.startObject()  
.field("Name", "Test")  
.field("BirthDate", new Date())  
.field("Email", "test@test.com")  
.field("bdate", "1234567890")  
.endObject()  
).execute()  
.actionGet();

But, when I'm doing search - I still get the \_source field , but on  
the other hand - the not\_analyzable field is indeed not participating  
in  
the search.  
What could be my mistake here ?

Thank You and Best Regards.

---

<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:** [June 2, 2011, 7:30am UTC](https://discuss.elastic.co/t/disable--source-field-store-or-enable-compression-for-it/4524/2 "2011-06-02T07:30:33Z")

</div>

The \_source needs to be on the same level as properties, not within it.

On Wednesday, June 1, 2011 at 11:20 PM, slavag wrote:

> Hi,  
> I wanted to disable storing \_source field and also to not make one of  
> the fields not analyzable, this is the code:  
> Client client = node.client();
> 
> XContentBuilder data = jsonBuilder().startObject()  
> .startObject("properties")  
> .startObject("bdate")  
> .field("type", "string")  
> .field("index", "not\_analyzed")  
> .field("store", "yes")  
> .endObject()  
> .startObject("\_source")  
> .field("enabled", false)  
> .endObject()  
> .endObject()  
> .endObject();
> 
> client.admin().indices().create(new  
> CreateIndexRequest("test").mapping("cont", data));  
> IndexResponse indexRes = client.prepareIndex("test", "cont", "1")  
> .setSource(jsonBuilder()  
> .startObject()  
> .field("Name", "Test")  
> .field("BirthDate", new Date())  
> .field("Email", "[test@test.com](mailto:test@test.com) ([mailto:test@test.com](mailto:test@test.com))")  
> .field("bdate", "1234567890")  
> .endObject()  
> ).execute()  
> .actionGet();
> 
> But, when I'm doing search - I still get the \_source field , but on  
> the other hand - the not\_analyzable field is indeed not participating  
> in  
> the search.  
> What could be my mistake here ?
> 
> Thank You and Best Regards.

---

<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, 4:04am UTC](https://discuss.elastic.co/t/disable--source-field-store-or-enable-compression-for-it/4524/3 "2017-07-06T04:04:56Z")

</div>

Closed on July 6, 2017, 4:04am UTC


