# Turn source store to false while using Java API

**URL:** <https://discuss.elastic.co/t/turn-source-store-to-false-while-using-java-api/12570>\
**Category:** Elasticsearch\
**Created:** [June 27, 2013, 11:02pm UTC](https://discuss.elastic.co/t/turn-source-store-to-false-while-using-java-api/12570 "2013-06-27T23:02:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gc1](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@gc1](https://discuss.elastic.co/u/gc1)\
**Post date:** [June 27, 2013, 11:02pm UTC](https://discuss.elastic.co/t/turn-source-store-to-false-while-using-java-api/12570/1 "2013-06-27T23:02:15Z")

</div>

Hi,

I have just started using elasticsearch to enable searching through our  
logs. However, I do not want to store the source in due to store overheads.

How can I set the \_source enabled to false using the Java API.

Appreciate any help.

Thanks,

gc

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 28, 2013, 3:12am UTC](https://discuss.elastic.co/t/turn-source-store-to-false-while-using-java-api/12570/2 "2013-06-28T03:12:03Z")

</div>

Use PutMapping API.

PutMappingResponse response = client.admin().indices()  
.preparePutMapping(index)  
.setType(type)  
.setSource(source).execute().actionGet();

In source, put a String or use XContentBuilder that produce  
{  
"tweet" : {  
"\_source" : {"enabled" : false}  
}  
}  
HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 28 juin 2013 à 01:02, gc [gitansh@gmail.com](mailto:gitansh@gmail.com) a écrit :

Hi,

I have just started using elasticsearch to enable searching through our logs. However, I do not want to store the source in due to store overheads.

How can I set the \_source enabled to false using the Java API.

Appreciate any help.

Thanks,

gc

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![gc1](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@gc1](https://discuss.elastic.co/u/gc1)\
**Post date:** [June 28, 2013, 7:10pm UTC](https://discuss.elastic.co/t/turn-source-store-to-false-while-using-java-api/12570/3 "2013-06-28T19:10:51Z")

</div>

Thank you David.

I tried to do this using the API and it get a successful response.

However, when I check the mapping it does not take effect.  
I tried using command line and same result.

Eg:  
curl -XPUT '[http://localhost:9200/abc/xyz/\_mapping](http://localhost:9200/abc/xyz/_mapping)' -d '  
{  
"xyz" : {  
"\_source" : {"enabled" : false}  
}  
}  
'  
{"ok":true,"acknowledged":true}

And when I query the mapping:  
{"abc":{"xyz":{"properties":{"channel":{"type":"string"},"customer":{"type":"string"},"message":{"type":"string"},"startDate":{"type":"string"}}}}}

Is there anything I need to run after I change the mapping?

On Thursday, June 27, 2013 8:12:03 PM UTC-7, David Pilato wrote:

> Use PutMapping API.
> 
> ```
> PutMappingResponse response = client.admin().indices() 
> 
> ```
> 
> .preparePutMapping(index)  
> .setType(type)
> 
> .setSource(source).execute().actionGet();
> 
> In source, put a String or use XContentBuilder that produce
> 
> {  
> "tweet" : {  
> "\_source" : {"enabled" : false}  
> }  
> }
> 
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 28 juin 2013 à 01:02, gc \<[git...@gmail.com](mailto:git...@gmail.com) \<javascript:\>\> a écrit :
> 
> Hi,
> 
> I have just started using elasticsearch to enable searching through our  
> logs. However, I do not want to store the source in due to store overheads.
> 
> How can I set the \_source enabled to false using the Java API.
> 
> Appreciate any help.
> 
> Thanks,
> 
> gc
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 28, 2013, 7:18pm UTC](https://discuss.elastic.co/t/turn-source-store-to-false-while-using-java-api/12570/4 "2013-06-28T19:18:17Z")

</div>

You can't change some properties on existing mapping.  
You need to delete it before (it will remove all docs) and then create it again.

It looks strange to me that you did not get an error here.

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 28 juin 2013 à 21:10, gc [gitansh@gmail.com](mailto:gitansh@gmail.com) a écrit :

Thank you David.

I tried to do this using the API and it get a successful response.

However, when I check the mapping it does not take effect.  
I tried using command line and same result.

Eg:  
curl -XPUT '[http://localhost:9200/abc/xyz/\_mapping](http://localhost:9200/abc/xyz/_mapping)' -d '  
{  
"xyz" : {  
"\_source" : {"enabled" : false}  
}  
}  
'  
{"ok":true,"acknowledged":true}

And when I query the mapping:  
{"abc":{"xyz":{"properties":{"channel":{"type":"string"},"customer":{"type":"string"},"message":{"type":"string"},"startDate":{"type":"string"}}}}}

Is there anything I need to run after I change the mapping?

On Thursday, June 27, 2013 8:12:03 PM UTC-7, David Pilato wrote:

> Use PutMapping API.
> 
> PutMappingResponse response = client.admin().indices()  
> .preparePutMapping(index)  
> .setType(type)  
> .setSource(source).execute().actionGet();
> 
> In source, put a String or use XContentBuilder that produce  
> {  
> "tweet" : {  
> "\_source" : {"enabled" : false}  
> }  
> }  
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 28 juin 2013 à 01:02, gc [git...@gmail.com](mailto:git...@gmail.com) a écrit :
> 
> Hi,
> 
> I have just started using elasticsearch to enable searching through our logs. However, I do not want to store the source in due to store overheads.
> 
> How can I set the \_source enabled to false using the Java API.
> 
> Appreciate any help.
> 
> Thanks,
> 
> gc
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).  
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:28am UTC](https://discuss.elastic.co/t/turn-source-store-to-false-while-using-java-api/12570/5 "2017-07-06T02:28:58Z")

</div>


