# Java API to disable source

**URL:** <https://discuss.elastic.co/t/java-api-to-disable-source/6660>\
**Category:** Elasticsearch\
**Created:** [February 9, 2012, 4:38pm UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660 "2012-02-09T16:38:15Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![thinusp](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@thinusp](https://discuss.elastic.co/u/thinusp)\
**Post date:** [February 9, 2012, 4:38pm UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/1 "2012-02-09T16:38:15Z")

</div>

I would like to disable saving the source with the indexes, but do it  
through the Java API. I believe the method to do it with JSON would  
be to use the "\_source" : {"enabled" : false} idea with the field, but  
I do not know how to do this with the API. Thank you!

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [February 9, 2012, 9:31pm UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/2 "2012-02-09T21:31:56Z")

</div>

Hi Thinus,

Try using updateSettings on the IndicesAdminClient with the relevant settings.

--  
Ivan

On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo  
[thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) wrote:

> I would like to disable saving the source with the indexes, but do it  
> through the Java API. I believe the method to do it with JSON would  
> be to use the "\_source" : {"enabled" : false} idea with the field, but  
> I do not know how to do this with the API. Thank you!

---

<div class="post-metadata">

**Author:** ![thinusp](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@thinusp](https://discuss.elastic.co/u/thinusp)\
**Post date:** [February 10, 2012, 8:03am UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/3 "2012-02-10T08:03:03Z")

</div>

Ivan, thanks!

Please could you help me a little bit more. The concepts here are a  
bit complicated.

This is what I have:

BulkRequestBuilder builder = tClient.prepareBulk();  
... (code to add documents to the builder)  
response = builder.execute().actionGet();

UpdateSettingsRequestBuilder usrb =  
client.admin().indices().prepareUpdateSettings(index);  
usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :  
false} } } "); \<-- Problem?

usrb.execute().actionGet();

The marked line is where I think things are going wrong, not that I  
get any sort of error to indicate so. I'd like to know, also, since  
I'm loading quite a few documents, would it not make sense to make  
this part of the bulk-request? In other words don't store the data to  
begin with. What I'm thinking of is something more towards the  
Field.Store.NO property (of Lucene) that I can set for every field  
separately. I'd like to do this programmatically as well, i.e. not  
with JSON commands if I don't have to.

Thanks for the effort.

On Feb 9, 11:31 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:

> Hi Thinus,
> 
> Try using updateSettings on the IndicesAdminClient with the relevant settings.
> 
> --  
> Ivan
> 
> On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> 
> [thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) wrote:
> 
> > I would like to disable saving the source with the indexes, but do it  
> > through the Java API. I believe the method to do it with JSON would  
> > be to use the "\_source" : {"enabled" : false} idea with the field, but  
> > I do not know how to do this with the API. Thank you!

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [February 10, 2012, 6:14pm UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/4 "2012-02-10T18:14:31Z")

</div>

Actually, I might be wrong since since the \_source setting is not an  
index setting, but a mapping property. In addition, I am not sure if  
it is even possible to change the \_source on a live index (never tried  
to).

Next step would be to look into the PutMappingRequest. Sorry if I was  
not too helpful.

--  
Ivan

On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo  
[thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) wrote:

> Ivan, thanks!
> 
> Please could you help me a little bit more. The concepts here are a  
> bit complicated.
> 
> This is what I have:
> 
> BulkRequestBuilder builder = tClient.prepareBulk();  
> ... (code to add documents to the builder)  
> response = builder.execute().actionGet();
> 
> UpdateSettingsRequestBuilder usrb =  
> client.admin().indices().prepareUpdateSettings(index);  
> usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :  
> false} } } "); \<-- Problem?
> 
> usrb.execute().actionGet();
> 
> The marked line is where I think things are going wrong, not that I  
> get any sort of error to indicate so. I'd like to know, also, since  
> I'm loading quite a few documents, would it not make sense to make  
> this part of the bulk-request? In other words don't store the data to  
> begin with. What I'm thinking of is something more towards the  
> Field.Store.NO property (of Lucene) that I can set for every field  
> separately. I'd like to do this programmatically as well, i.e. not  
> with JSON commands if I don't have to.
> 
> Thanks for the effort.
> 
> On Feb 9, 11:31 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:
> 
> > Hi Thinus,
> > 
> > Try using updateSettings on the IndicesAdminClient with the relevant settings.
> > 
> > --  
> > Ivan
> > 
> > On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> > 
> > [thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) wrote:
> > 
> > > I would like to disable saving the source with the indexes, but do it  
> > > through the Java API. I believe the method to do it with JSON would  
> > > be to use the "\_source" : {"enabled" : false} idea with the field, but  
> > > I do not know how to do this with the API. Thank you!

---

<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:** [February 12, 2012, 2:45pm UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/5 "2012-02-12T14:45:28Z")

</div>

Yea, update settings is for settings, not mappings. The best way to configure it is to set the relevant mapping when you create the index. You can have a mapping type called _default_ to apply it to all mappings in that index. Moreoever, you can create an index template that matches on all indices (a template of \*), with _default_ mapping that disables source. This will disable source on all indices created in the cluster.

On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:

> Actually, I might be wrong since since the \_source setting is not an  
> index setting, but a mapping property. In addition, I am not sure if  
> it is even possible to change the \_source on a live index (never tried  
> to).
> 
> Next step would be to look into the PutMappingRequest. Sorry if I was  
> not too helpful.
> 
> --  
> Ivan
> 
> On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo  
> \<[thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) ([mailto:thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com))\> wrote:
> 
> > Ivan, thanks!
> > 
> > Please could you help me a little bit more. The concepts here are a  
> > bit complicated.
> > 
> > This is what I have:
> > 
> > BulkRequestBuilder builder = tClient.prepareBulk();  
> > ... (code to add documents to the builder)  
> > response = builder.execute().actionGet();
> > 
> > UpdateSettingsRequestBuilder usrb =  
> > client.admin().indices().prepareUpdateSettings(index);  
> > usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :  
> > false} } } "); \<-- Problem?
> > 
> > usrb.execute().actionGet();
> > 
> > The marked line is where I think things are going wrong, not that I  
> > get any sort of error to indicate so. I'd like to know, also, since  
> > I'm loading quite a few documents, would it not make sense to make  
> > this part of the bulk-request? In other words don't store the data to  
> > begin with. What I'm thinking of is something more towards the  
> > Field.Store.NO property (of Lucene) that I can set for every field  
> > separately. I'd like to do this programmatically as well, i.e. not  
> > with JSON commands if I don't have to.
> > 
> > Thanks for the effort.
> > 
> > On Feb 9, 11:31 pm, Ivan Brusic \<[i...@brusic.com](mailto:i...@brusic.com) ([http://brusic.com](http://brusic.com))\> wrote:
> > 
> > > Hi Thinus,
> > > 
> > > Try using updateSettings on the IndicesAdminClient with the relevant settings.
> > > 
> > > --  
> > > Ivan
> > > 
> > > On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> > > 
> > > \<[thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > > 
> > > > I would like to disable saving the source with the indexes, but do it  
> > > > through the Java API. I believe the method to do it with JSON would  
> > > > be to use the "\_source" : {"enabled" : false} idea with the field, but  
> > > > I do not know how to do this with the API. Thank you!

---

<div class="post-metadata">

**Author:** ![thinusp](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@thinusp](https://discuss.elastic.co/u/thinusp)\
**Post date:** [February 13, 2012, 7:50am UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/6 "2012-02-13T07:50:57Z")

</div>

Shay,

Thank you, that seemed to do the trick. It's not pretty, imho, but it  
works. I "create" the index first, using JSON and setting \_source  
enabled to false, then from there on I load the data fields in the  
usual way. It would be nice if there was some option in the API  
itself to disable the source, but for now this will do.

Thanks for the support Ivan and Shay!

On Feb 12, 4:45 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Yea, update settings is for settings, not mappings. The best way to configure it is to set the relevant mapping when you create the index. You can have a mapping type called _default_ to apply it to all mappings in that index. Moreoever, you can create an index template that matches on all indices (a template of \*), with _default_ mapping that disables source. This will disable source on all indices created in the cluster.
> 
> On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:
> 
> > Actually, I might be wrong since since the \_source setting is not an  
> > index setting, but a mapping property. In addition, I am not sure if  
> > it is even possible to change the \_source on a live index (never tried  
> > to).
> 
> > Next step would be to look into the PutMappingRequest. Sorry if I was  
> > not too helpful.
> 
> > --  
> > Ivan
> 
> > On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo  
> > \<[thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) ([mailto:thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com))\> wrote:
> > 
> > > Ivan, thanks!
> 
> > > Please could you help me a little bit more. The concepts here are a  
> > > bit complicated.
> 
> > > This is what I have:
> 
> > > BulkRequestBuilder builder = tClient.prepareBulk();  
> > > ... (code to add documents to the builder)  
> > > response = builder.execute().actionGet();
> 
> > > UpdateSettingsRequestBuilder usrb =  
> > > client.admin().indices().prepareUpdateSettings(index);  
> > > usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :  
> > > false} } } "); \<-- Problem?
> 
> > > usrb.execute().actionGet();
> 
> > > The marked line is where I think things are going wrong, not that I  
> > > get any sort of error to indicate so. I'd like to know, also, since  
> > > I'm loading quite a few documents, would it not make sense to make  
> > > this part of the bulk-request? In other words don't store the data to  
> > > begin with. What I'm thinking of is something more towards the  
> > > Field.Store.NO property (of Lucene) that I can set for every field  
> > > separately. I'd like to do this programmatically as well, i.e. not  
> > > with JSON commands if I don't have to.
> 
> > > Thanks for the effort.
> 
> > > On Feb 9, 11:31 pm, Ivan Brusic \<[i...@brusic.com](mailto:i...@brusic.com) ([http://brusic.com](http://brusic.com))\> wrote:
> > > 
> > > > Hi Thinus,
> 
> > > > Try using updateSettings on the IndicesAdminClient with the relevant settings.
> 
> > > > --  
> > > > Ivan
> 
> > > > On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> 
> > > > \<[thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > > > 
> > > > > I would like to disable saving the source with the indexes, but do it  
> > > > > through the Java API. I believe the method to do it with JSON would  
> > > > > be to use the "\_source" : {"enabled" : false} idea with the field, but  
> > > > > I do not know how to do this with the API. Thank you!

---

<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:** [February 13, 2012, 6:29pm UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/7 "2012-02-13T18:29:29Z")

</div>

Not sure I agree that being able to disable the source on the API level is better…, the mappings allows for one time worry free option if source is stored or not.

On Monday, February 13, 2012 at 9:50 AM, Thinus Prinsloo wrote:

> Shay,
> 
> Thank you, that seemed to do the trick. It's not pretty, imho, but it  
> works. I "create" the index first, using JSON and setting \_source  
> enabled to false, then from there on I load the data fields in the  
> usual way. It would be nice if there was some option in the API  
> itself to disable the source, but for now this will do.
> 
> Thanks for the support Ivan and Shay!
> 
> On Feb 12, 4:45 pm, Shay Banon \<[kim...@gmail.com](mailto:kim...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> 
> > Yea, update settings is for settings, not mappings. The best way to configure it is to set the relevant mapping when you create the index. You can have a mapping type called _default_ to apply it to all mappings in that index. Moreoever, you can create an index template that matches on all indices (a template of \*), with _default_ mapping that disables source. This will disable source on all indices created in the cluster.
> > 
> > On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:
> > 
> > > Actually, I might be wrong since since the \_source setting is not an  
> > > index setting, but a mapping property. In addition, I am not sure if  
> > > it is even possible to change the \_source on a live index (never tried  
> > > to).
> > 
> > > Next step would be to look into the PutMappingRequest. Sorry if I was  
> > > not too helpful.
> > 
> > > --  
> > > Ivan
> > 
> > > On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo  
> > > \<[thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) ([mailto:thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) ([http://gmail.com](http://gmail.com)))\> wrote:
> > > 
> > > > Ivan, thanks!
> > 
> > > > Please could you help me a little bit more. The concepts here are a  
> > > > bit complicated.
> > 
> > > > This is what I have:
> > 
> > > > BulkRequestBuilder builder = tClient.prepareBulk();  
> > > > ... (code to add documents to the builder)  
> > > > response = builder.execute().actionGet();
> > 
> > > > UpdateSettingsRequestBuilder usrb =  
> > > > client.admin().indices().prepareUpdateSettings(index);  
> > > > usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :  
> > > > false} } } "); \<-- Problem?
> > 
> > > > usrb.execute().actionGet();
> > 
> > > > The marked line is where I think things are going wrong, not that I  
> > > > get any sort of error to indicate so. I'd like to know, also, since  
> > > > I'm loading quite a few documents, would it not make sense to make  
> > > > this part of the bulk-request? In other words don't store the data to  
> > > > begin with. What I'm thinking of is something more towards the  
> > > > Field.Store.NO property (of Lucene) that I can set for every field  
> > > > separately. I'd like to do this programmatically as well, i.e. not  
> > > > with JSON commands if I don't have to.
> > 
> > > > Thanks for the effort.
> > 
> > > > On Feb 9, 11:31 pm, Ivan Brusic \<[i...@brusic.com](mailto:i...@brusic.com) ([http://brusic.com](http://brusic.com))\> wrote:
> > > > 
> > > > > Hi Thinus,
> > 
> > > > > Try using updateSettings on the IndicesAdminClient with the relevant settings.
> > 
> > > > > --  
> > > > > Ivan
> > 
> > > > > On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> > 
> > > > > \<[thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > > > > 
> > > > > > I would like to disable saving the source with the indexes, but do it  
> > > > > > through the Java API. I believe the method to do it with JSON would  
> > > > > > be to use the "\_source" : {"enabled" : false} idea with the field, but  
> > > > > > I do not know how to do this with the API. Thank you!

---

<div class="post-metadata">

**Author:** ![thinusp](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@thinusp](https://discuss.elastic.co/u/thinusp)\
**Post date:** [February 14, 2012, 6:09am UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/8 "2012-02-14T06:09:02Z")

</div>

Shay,

I actually agree with you. I suppose what would be nice is to have  
the option to construct the table (say during the PrepareBulkRequest  
process) and in this stage, once as you point out, set the mapping to  
false. But I agree, since you create a table once and then populate  
it with fields, this option should not be with the field itself.

On Feb 13, 8:29 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Not sure I agree that being able to disable the source on the API level is better…, the mappings allows for one time worry free option if source is stored or not.
> 
> On Monday, February 13, 2012 at 9:50 AM, Thinus Prinsloo wrote:
> 
> > Shay,
> 
> > Thank you, that seemed to do the trick. It's not pretty, imho, but it  
> > works. I "create" the index first, using JSON and setting \_source  
> > enabled to false, then from there on I load the data fields in the  
> > usual way. It would be nice if there was some option in the API  
> > itself to disable the source, but for now this will do.
> 
> > Thanks for the support Ivan and Shay!
> 
> > On Feb 12, 4:45 pm, Shay Banon \<[kim...@gmail.com](mailto:kim...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > 
> > > Yea, update settings is for settings, not mappings. The best way to configure it is to set the relevant mapping when you create the index. You can have a mapping type called _default_ to apply it to all mappings in that index. Moreoever, you can create an index template that matches on all indices (a template of \*), with _default_ mapping that disables source. This will disable source on all indices created in the cluster.
> 
> > > On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:
> > > 
> > > > Actually, I might be wrong since since the \_source setting is not an  
> > > > index setting, but a mapping property. In addition, I am not sure if  
> > > > it is even possible to change the \_source on a live index (never tried  
> > > > to).
> 
> > > > Next step would be to look into the PutMappingRequest. Sorry if I was  
> > > > not too helpful.
> 
> > > > --  
> > > > Ivan
> 
> > > > On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo  
> > > > \<[thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) ([mailto:thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) ([http://gmail.com](http://gmail.com)))\> wrote:
> > > > 
> > > > > Ivan, thanks!
> 
> > > > > Please could you help me a little bit more. The concepts here are a  
> > > > > bit complicated.
> 
> > > > > This is what I have:
> 
> > > > > BulkRequestBuilder builder = tClient.prepareBulk();  
> > > > > ... (code to add documents to the builder)  
> > > > > response = builder.execute().actionGet();
> 
> > > > > UpdateSettingsRequestBuilder usrb =  
> > > > > client.admin().indices().prepareUpdateSettings(index);  
> > > > > usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :  
> > > > > false} } } "); \<-- Problem?
> 
> > > > > usrb.execute().actionGet();
> 
> > > > > The marked line is where I think things are going wrong, not that I  
> > > > > get any sort of error to indicate so. I'd like to know, also, since  
> > > > > I'm loading quite a few documents, would it not make sense to make  
> > > > > this part of the bulk-request? In other words don't store the data to  
> > > > > begin with. What I'm thinking of is something more towards the  
> > > > > Field.Store.NO property (of Lucene) that I can set for every field  
> > > > > separately. I'd like to do this programmatically as well, i.e. not  
> > > > > with JSON commands if I don't have to.
> 
> > > > > Thanks for the effort.
> 
> > > > > On Feb 9, 11:31 pm, Ivan Brusic \<[i...@brusic.com](mailto:i...@brusic.com) ([http://brusic.com](http://brusic.com))\> wrote:
> > > > > 
> > > > > > Hi Thinus,
> 
> > > > > > Try using updateSettings on the IndicesAdminClient with the relevant settings.
> 
> > > > > > --  
> > > > > > Ivan
> 
> > > > > > On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> 
> > > > > > \<[thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > > > > > 
> > > > > > > I would like to disable saving the source with the indexes, but do it  
> > > > > > > through the Java API. I believe the method to do it with JSON would  
> > > > > > > be to use the "\_source" : {"enabled" : false} idea with the field, but  
> > > > > > > I do not know how to do this with the API. Thank you!

---

<div class="post-metadata">

**Author:** ![elfreyshira](https://avatars.discourse-cdn.com/v4/letter/e/47e85d/32.png) [@elfreyshira](https://discuss.elastic.co/u/elfreyshira)\
**Post date:** [July 23, 2012, 6:27pm UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/9 "2012-07-23T18:27:17Z")

</div>

kimchy,

Thanks for the responding to Thinus. I also have the same question as  
Thinus: how do I disable the \_source through Java.

I would like an answer with more details please. Where and how would I set  
this default mapping? Can you provide some sample code?

I am quite new to the elasticsearch world (about two days, actually), so  
I'd appreciate the help!

Thanks,  
Elfrey

On Sunday, February 12, 2012 8:45:28 AM UTC-6, kimchy wrote:

> Yea, update settings is for settings, not mappings. The best way to  
> configure it is to set the relevant mapping when you create the index. You  
> can have a mapping type called _default_ to apply it to all mappings in  
> that index. Moreoever, you can create an index template that matches on all  
> indices (a template of \*), with _default_ mapping that disables source.  
> This will disable source on all indices created in the cluster.
> 
> On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:
> 
> Actually, I might be wrong since since the \_source setting is not an  
> index setting, but a mapping property. In addition, I am not sure if  
> it is even possible to change the \_source on a live index (never tried  
> to).
> 
> Next step would be to look into the PutMappingRequest. Sorry if I was  
> not too helpful.
> 
> --  
> Ivan
> 
> On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo  
> [thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) wrote:
> 
> Ivan, thanks!
> 
> Please could you help me a little bit more. The concepts here are a  
> bit complicated.
> 
> This is what I have:
> 
> BulkRequestBuilder builder = tClient.prepareBulk();  
> ... (code to add documents to the builder)  
> response = builder.execute().actionGet();
> 
> UpdateSettingsRequestBuilder usrb =  
> client.admin().indices().prepareUpdateSettings(index);  
> usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :  
> false} } } "); \<-- Problem?
> 
> usrb.execute().actionGet();
> 
> The marked line is where I think things are going wrong, not that I  
> get any sort of error to indicate so. I'd like to know, also, since  
> I'm loading quite a few documents, would it not make sense to make  
> this part of the bulk-request? In other words don't store the data to  
> begin with. What I'm thinking of is something more towards the  
> Field.Store.NO property (of Lucene) that I can set for every field  
> separately. I'd like to do this programmatically as well, i.e. not  
> with JSON commands if I don't have to.
> 
> Thanks for the effort.
> 
> On Feb 9, 11:31 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:
> 
> Hi Thinus,
> 
> Try using updateSettings on the IndicesAdminClient with the relevant  
> settings.
> 
> --  
> Ivan
> 
> On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> 
> [thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) wrote:
> 
> I would like to disable saving the source with the indexes, but do it  
> through the Java API. I believe the method to do it with JSON would  
> be to use the "\_source" : {"enabled" : false} idea with the field, but  
> I do not know how to do this with the API. Thank you!

On Sunday, February 12, 2012 8:45:28 AM UTC-6, kimchy wrote:

> Yea, update settings is for settings, not mappings. The best way to  
> configure it is to set the relevant mapping when you create the index. You  
> can have a mapping type called _default_ to apply it to all mappings in  
> that index. Moreoever, you can create an index template that matches on all  
> indices (a template of \*), with _default_ mapping that disables source.  
> This will disable source on all indices created in the cluster.
> 
> On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:
> 
> Actually, I might be wrong since since the \_source setting is not an  
> index setting, but a mapping property. In addition, I am not sure if  
> it is even possible to change the \_source on a live index (never tried  
> to).
> 
> Next step would be to look into the PutMappingRequest. Sorry if I was  
> not too helpful.
> 
> --  
> Ivan
> 
> On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo  
> [thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) wrote:
> 
> Ivan, thanks!
> 
> Please could you help me a little bit more. The concepts here are a  
> bit complicated.
> 
> This is what I have:
> 
> BulkRequestBuilder builder = tClient.prepareBulk();  
> ... (code to add documents to the builder)  
> response = builder.execute().actionGet();
> 
> UpdateSettingsRequestBuilder usrb =  
> client.admin().indices().prepareUpdateSettings(index);  
> usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :  
> false} } } "); \<-- Problem?
> 
> usrb.execute().actionGet();
> 
> The marked line is where I think things are going wrong, not that I  
> get any sort of error to indicate so. I'd like to know, also, since  
> I'm loading quite a few documents, would it not make sense to make  
> this part of the bulk-request? In other words don't store the data to  
> begin with. What I'm thinking of is something more towards the  
> Field.Store.NO property (of Lucene) that I can set for every field  
> separately. I'd like to do this programmatically as well, i.e. not  
> with JSON commands if I don't have to.
> 
> Thanks for the effort.
> 
> On Feb 9, 11:31 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:
> 
> Hi Thinus,
> 
> Try using updateSettings on the IndicesAdminClient with the relevant  
> settings.
> 
> --  
> Ivan
> 
> On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> 
> [thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) wrote:
> 
> I would like to disable saving the source with the indexes, but do it  
> through the Java API. I believe the method to do it with JSON would  
> be to use the "\_source" : {"enabled" : false} idea with the field, but  
> I do not know how to do this with the API. Thank you!

On Sunday, February 12, 2012 8:45:28 AM UTC-6, kimchy wrote:

> Yea, update settings is for settings, not mappings. The best way to  
> configure it is to set the relevant mapping when you create the index. You  
> can have a mapping type called _default_ to apply it to all mappings in  
> that index. Moreoever, you can create an index template that matches on all  
> indices (a template of \*), with _default_ mapping that disables source.  
> This will disable source on all indices created in the cluster.
> 
> On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:
> 
> Actually, I might be wrong since since the \_source setting is not an  
> index setting, but a mapping property. In addition, I am not sure if  
> it is even possible to change the \_source on a live index (never tried  
> to).
> 
> Next step would be to look into the PutMappingRequest. Sorry if I was  
> not too helpful.
> 
> --  
> Ivan
> 
> On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo  
> [thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) wrote:
> 
> Ivan, thanks!
> 
> Please could you help me a little bit more. The concepts here are a  
> bit complicated.
> 
> This is what I have:
> 
> BulkRequestBuilder builder = tClient.prepareBulk();  
> ... (code to add documents to the builder)  
> response = builder.execute().actionGet();
> 
> UpdateSettingsRequestBuilder usrb =  
> client.admin().indices().prepareUpdateSettings(index);  
> usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :  
> false} } } "); \<-- Problem?
> 
> usrb.execute().actionGet();
> 
> The marked line is where I think things are going wrong, not that I  
> get any sort of error to indicate so. I'd like to know, also, since  
> I'm loading quite a few documents, would it not make sense to make  
> this part of the bulk-request? In other words don't store the data to  
> begin with. What I'm thinking of is something more towards the  
> Field.Store.NO property (of Lucene) that I can set for every field  
> separately. I'd like to do this programmatically as well, i.e. not  
> with JSON commands if I don't have to.
> 
> Thanks for the effort.
> 
> On Feb 9, 11:31 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:
> 
> Hi Thinus,
> 
> Try using updateSettings on the IndicesAdminClient with the relevant  
> settings.
> 
> --  
> Ivan
> 
> On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> 
> [thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) wrote:
> 
> I would like to disable saving the source with the indexes, but do it  
> through the Java API. I believe the method to do it with JSON would  
> be to use the "\_source" : {"enabled" : false} idea with the field, but  
> I do not know how to do this with the API. Thank you!

---

<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:** [July 23, 2012, 7:27pm UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/10 "2012-07-23T19:27:23Z")

</div>

Hi Elfrey,

You probably could write something like:

```
   XContentBuilder xb = jsonBuilder()

         .startObject()

                .startObject("mytype")

                       .field("_source", "disabled")

                       .startObject("properties")

                              .startObject("myfield").field("type", "string").endObject()

                       .endObject()

                .endObject()

         .endObject();

         

   PutMappingRequestBuilder pmrb = client.admin().indices()

         .preparePutMapping("myindex")

         .setType("mytype").setSource(xb).execute().actionGet();                   

```

Hope this helps

David.

De : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] De la part de elfreyshira  
Envoyé : lundi 23 juillet 2012 20:27  
À : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
Objet : Re: Java API to disable source

kimchy,

Thanks for the responding to Thinus. I also have the same question as Thinus: how do I disable the \_source through Java.

I would like an answer with more details please. Where and how would I set this default mapping? Can you provide some sample code?

I am quite new to the elasticsearch world (about two days, actually), so I'd appreciate the help!

Thanks,

Elfrey

On Sunday, February 12, 2012 8:45:28 AM UTC-6, kimchy wrote:

Yea, update settings is for settings, not mappings. The best way to configure it is to set the relevant mapping when you create the index. You can have a mapping type called _default_ to apply it to all mappings in that index. Moreoever, you can create an index template that matches on all indices (a template of \*), with _default_ mapping that disables source. This will disable source on all indices created in the cluster.

On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:

Actually, I might be wrong since since the \_source setting is not an

index setting, but a mapping property. In addition, I am not sure if

it is even possible to change the \_source on a live index (never tried

to).

Next step would be to look into the PutMappingRequest. Sorry if I was

not too helpful.

--

Ivan

On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo

[thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) wrote:

Ivan, thanks!

Please could you help me a little bit more. The concepts here are a

bit complicated.

This is what I have:

BulkRequestBuilder builder = tClient.prepareBulk();

... (code to add documents to the builder)

response = builder.execute().actionGet();

UpdateSettingsRequestBuilder usrb =

client.admin().indices().prepareUpdateSettings(index);

usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :

false} } } "); \<-- Problem?

usrb.execute().actionGet();

The marked line is where I think things are going wrong, not that I

get any sort of error to indicate so. I'd like to know, also, since

I'm loading quite a few documents, would it not make sense to make

this part of the bulk-request? In other words don't store the data to

begin with. What I'm thinking of is something more towards the

Field.Store.NO property (of Lucene) that I can set for every field

separately. I'd like to do this programmatically as well, i.e. not

with JSON commands if I don't have to.

Thanks for the effort.

On Feb 9, 11:31 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:

Hi Thinus,

Try using updateSettings on the IndicesAdminClient with the relevant settings.

--

Ivan

On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo

[thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) wrote:

I would like to disable saving the source with the indexes, but do it

through the Java API. I believe the method to do it with JSON would

be to use the "\_source" : {"enabled" : false} idea with the field, but

I do not know how to do this with the API. Thank you!

On Sunday, February 12, 2012 8:45:28 AM UTC-6, kimchy wrote:

Yea, update settings is for settings, not mappings. The best way to configure it is to set the relevant mapping when you create the index. You can have a mapping type called _default_ to apply it to all mappings in that index. Moreoever, you can create an index template that matches on all indices (a template of \*), with _default_ mapping that disables source. This will disable source on all indices created in the cluster.

On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:

Actually, I might be wrong since since the \_source setting is not an

index setting, but a mapping property. In addition, I am not sure if

it is even possible to change the \_source on a live index (never tried

to).

Next step would be to look into the PutMappingRequest. Sorry if I was

not too helpful.

--

Ivan

On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo

[thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) wrote:

Ivan, thanks!

Please could you help me a little bit more. The concepts here are a

bit complicated.

This is what I have:

BulkRequestBuilder builder = tClient.prepareBulk();

... (code to add documents to the builder)

response = builder.execute().actionGet();

UpdateSettingsRequestBuilder usrb =

client.admin().indices().prepareUpdateSettings(index);

usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :

false} } } "); \<-- Problem?

usrb.execute().actionGet();

The marked line is where I think things are going wrong, not that I

get any sort of error to indicate so. I'd like to know, also, since

I'm loading quite a few documents, would it not make sense to make

this part of the bulk-request? In other words don't store the data to

begin with. What I'm thinking of is something more towards the

Field.Store.NO property (of Lucene) that I can set for every field

separately. I'd like to do this programmatically as well, i.e. not

with JSON commands if I don't have to.

Thanks for the effort.

On Feb 9, 11:31 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:

Hi Thinus,

Try using updateSettings on the IndicesAdminClient with the relevant settings.

--

Ivan

On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo

[thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) wrote:

I would like to disable saving the source with the indexes, but do it

through the Java API. I believe the method to do it with JSON would

be to use the "\_source" : {"enabled" : false} idea with the field, but

I do not know how to do this with the API. Thank you!

On Sunday, February 12, 2012 8:45:28 AM UTC-6, kimchy wrote:

Yea, update settings is for settings, not mappings. The best way to configure it is to set the relevant mapping when you create the index. You can have a mapping type called _default_ to apply it to all mappings in that index. Moreoever, you can create an index template that matches on all indices (a template of \*), with _default_ mapping that disables source. This will disable source on all indices created in the cluster.

On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:

Actually, I might be wrong since since the \_source setting is not an

index setting, but a mapping property. In addition, I am not sure if

it is even possible to change the \_source on a live index (never tried

to).

Next step would be to look into the PutMappingRequest. Sorry if I was

not too helpful.

--

Ivan

On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo

[thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) wrote:

Ivan, thanks!

Please could you help me a little bit more. The concepts here are a

bit complicated.

This is what I have:

BulkRequestBuilder builder = tClient.prepareBulk();

... (code to add documents to the builder)

response = builder.execute().actionGet();

UpdateSettingsRequestBuilder usrb =

client.admin().indices().prepareUpdateSettings(index);

usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :

false} } } "); \<-- Problem?

usrb.execute().actionGet();

The marked line is where I think things are going wrong, not that I

get any sort of error to indicate so. I'd like to know, also, since

I'm loading quite a few documents, would it not make sense to make

this part of the bulk-request? In other words don't store the data to

begin with. What I'm thinking of is something more towards the

Field.Store.NO property (of Lucene) that I can set for every field

separately. I'd like to do this programmatically as well, i.e. not

with JSON commands if I don't have to.

Thanks for the effort.

On Feb 9, 11:31 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:

Hi Thinus,

Try using updateSettings on the IndicesAdminClient with the relevant settings.

--

Ivan

On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo

[thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) wrote:

I would like to disable saving the source with the indexes, but do it

through the Java API. I believe the method to do it with JSON would

be to use the "\_source" : {"enabled" : false} idea with the field, but

I do not know how to do this with the API. Thank you!

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [July 24, 2012, 10:48pm UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/11 "2012-07-24T22:48:38Z")

</div>

Hi Elfrey,

Here is a slightly modified version of David's example for disabling source  
that you might want to try:

```
    XContentBuilder xb = jsonBuilder()
        .startObject()
            .startObject("mytype")
            .startObject("_source").field("enabled", false).endObject()
            .startObject("properties")
                .startObject("myfield").field("type", 

```

"string").endObject()  
.endObject()  
.endObject()  
.endObject();

```
    PutMappingResponse pmrb = client.admin().indices()
            .preparePutMapping("myindex")
            .setType("mytype").setSource(xb).execute().actionGet();

```

In general, take a look at elasticsearch integration tests[https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/test/unit/index/mapper/source/DefaultSourceMappingTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/test/unit/index/mapper/source/DefaultSourceMappingTests.java).  
That's a great source of information about usage of Java API.

Igor

On Monday, July 23, 2012 3:27:23 PM UTC-4, David Pilato wrote:

> Hi Elfrey,
> 
> You probably could write something like:
> 
> ```
> XContentBuilder xb = *jsonBuilder*()
> 
> .startObject()
> 
> .startObject("mytype")
> 
> .field("_source", "disabled")
> 
> .startObject("properties")
> 
> .startObject("myfield").field("type", 
> 
> ```
> 
> "string").endObject()
> 
> ```
> .endObject()
> 
> .endObject()
> 
> .endObject();
> 
>          
> 
> PutMappingRequestBuilder pmrb = client.admin().indices()
> 
> .preparePutMapping("myindex")
> 
> .setType("mytype").setSource(xb).execute().actionGet();                   
> 
> ```
> 
> - 
> - 
> 
> - 
> - 
> 
> Hope this helps
> 
> David.
> 
> _De :_ [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) [mailto:  
> [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] _De la part de_ elfreyshira  
> _Envoyé :_ lundi 23 juillet 2012 20:27  
> _À :_ [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
> _Objet :_ Re: Java API to disable source
> 
> kimchy,
> 
> Thanks for the responding to Thinus. I also have the same question as  
> Thinus: how do I disable the \_source through Java.
> 
> I would like an answer with more details please. Where and how would I set  
> this default mapping? Can you provide some sample code?
> 
> I am quite new to the elasticsearch world (about two days, actually), so  
> I'd appreciate the help!
> 
> Thanks,
> 
> Elfrey
> 
> On Sunday, February 12, 2012 8:45:28 AM UTC-6, kimchy wrote:
> 
> Yea, update settings is for settings, not mappings. The best way to  
> configure it is to set the relevant mapping when you create the index. You  
> can have a mapping type called _default_ to apply it to all mappings in  
> that index. Moreoever, you can create an index template that matches on all  
> indices (a template of \*), with _default_ mapping that disables source.  
> This will disable source on all indices created in the cluster.
> 
> On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:
> 
> Actually, I might be wrong since since the \_source setting is not an
> 
> index setting, but a mapping property. In addition, I am not sure if
> 
> it is even possible to change the \_source on a live index (never tried
> 
> to).
> 
> Next step would be to look into the PutMappingRequest. Sorry if I was
> 
> not too helpful.
> 
> --
> 
> Ivan
> 
> On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo
> 
> [thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) wrote:
> 
> Ivan, thanks!
> 
> Please could you help me a little bit more. The concepts here are a
> 
> bit complicated.
> 
> This is what I have:
> 
> BulkRequestBuilder builder = tClient.prepareBulk();
> 
> ... (code to add documents to the builder)
> 
> response = builder.execute().actionGet();
> 
> UpdateSettingsRequestBuilder usrb =
> 
> client.admin().indices().prepareUpdateSettings(index);
> 
> usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :
> 
> false} } } "); \<-- Problem?
> 
> usrb.execute().actionGet();
> 
> The marked line is where I think things are going wrong, not that I
> 
> get any sort of error to indicate so. I'd like to know, also, since
> 
> I'm loading quite a few documents, would it not make sense to make
> 
> this part of the bulk-request? In other words don't store the data to
> 
> begin with. What I'm thinking of is something more towards the
> 
> Field.Store.NO property (of Lucene) that I can set for every field
> 
> separately. I'd like to do this programmatically as well, i.e. not
> 
> with JSON commands if I don't have to.
> 
> Thanks for the effort.
> 
> On Feb 9, 11:31 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:
> 
> Hi Thinus,
> 
> Try using updateSettings on the IndicesAdminClient with the relevant  
> settings.
> 
> --
> 
> Ivan
> 
> On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> 
> [thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) wrote:
> 
> I would like to disable saving the source with the indexes, but do it
> 
> through the Java API. I believe the method to do it with JSON would
> 
> be to use the "\_source" : {"enabled" : false} idea with the field, but
> 
> I do not know how to do this with the API. Thank you!
> 
> On Sunday, February 12, 2012 8:45:28 AM UTC-6, kimchy wrote:
> 
> Yea, update settings is for settings, not mappings. The best way to  
> configure it is to set the relevant mapping when you create the index. You  
> can have a mapping type called _default_ to apply it to all mappings in  
> that index. Moreoever, you can create an index template that matches on all  
> indices (a template of \*), with _default_ mapping that disables source.  
> This will disable source on all indices created in the cluster.
> 
> On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:
> 
> Actually, I might be wrong since since the \_source setting is not an
> 
> index setting, but a mapping property. In addition, I am not sure if
> 
> it is even possible to change the \_source on a live index (never tried
> 
> to).
> 
> Next step would be to look into the PutMappingRequest. Sorry if I was
> 
> not too helpful.
> 
> --
> 
> Ivan
> 
> On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo
> 
> [thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) wrote:
> 
> Ivan, thanks!
> 
> Please could you help me a little bit more. The concepts here are a
> 
> bit complicated.
> 
> This is what I have:
> 
> BulkRequestBuilder builder = tClient.prepareBulk();
> 
> ... (code to add documents to the builder)
> 
> response = builder.execute().actionGet();
> 
> UpdateSettingsRequestBuilder usrb =
> 
> client.admin().indices().prepareUpdateSettings(index);
> 
> usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :
> 
> false} } } "); \<-- Problem?
> 
> usrb.execute().actionGet();
> 
> The marked line is where I think things are going wrong, not that I
> 
> get any sort of error to indicate so. I'd like to know, also, since
> 
> I'm loading quite a few documents, would it not make sense to make
> 
> this part of the bulk-request? In other words don't store the data to
> 
> begin with. What I'm thinking of is something more towards the
> 
> Field.Store.NO property (of Lucene) that I can set for every field
> 
> separately. I'd like to do this programmatically as well, i.e. not
> 
> with JSON commands if I don't have to.
> 
> Thanks for the effort.
> 
> On Feb 9, 11:31 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:
> 
> Hi Thinus,
> 
> Try using updateSettings on the IndicesAdminClient with the relevant  
> settings.
> 
> --
> 
> Ivan
> 
> On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> 
> [thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) wrote:
> 
> I would like to disable saving the source with the indexes, but do it
> 
> through the Java API. I believe the method to do it with JSON would
> 
> be to use the "\_source" : {"enabled" : false} idea with the field, but
> 
> I do not know how to do this with the API. Thank you!
> 
> On Sunday, February 12, 2012 8:45:28 AM UTC-6, kimchy wrote:
> 
> Yea, update settings is for settings, not mappings. The best way to  
> configure it is to set the relevant mapping when you create the index. You  
> can have a mapping type called _default_ to apply it to all mappings in  
> that index. Moreoever, you can create an index template that matches on all  
> indices (a template of \*), with _default_ mapping that disables source.  
> This will disable source on all indices created in the cluster.
> 
> On Friday, February 10, 2012 at 8:14 PM, Ivan Brusic wrote:
> 
> Actually, I might be wrong since since the \_source setting is not an
> 
> index setting, but a mapping property. In addition, I am not sure if
> 
> it is even possible to change the \_source on a live index (never tried
> 
> to).
> 
> Next step would be to look into the PutMappingRequest. Sorry if I was
> 
> not too helpful.
> 
> --
> 
> Ivan
> 
> On Fri, Feb 10, 2012 at 12:03 AM, Thinus Prinsloo
> 
> [thinus.prinsloo@gmail.com](mailto:thinus.prinsloo@gmail.com) wrote:
> 
> Ivan, thanks!
> 
> Please could you help me a little bit more. The concepts here are a
> 
> bit complicated.
> 
> This is what I have:
> 
> BulkRequestBuilder builder = tClient.prepareBulk();
> 
> ... (code to add documents to the builder)
> 
> response = builder.execute().actionGet();
> 
> UpdateSettingsRequestBuilder usrb =
> 
> client.admin().indices().prepareUpdateSettings(index);
> 
> usrb.setSettings( " { "theindex" : { "\_source" : {"enabled" :
> 
> false} } } "); \<-- Problem?
> 
> usrb.execute().actionGet();
> 
> The marked line is where I think things are going wrong, not that I
> 
> get any sort of error to indicate so. I'd like to know, also, since
> 
> I'm loading quite a few documents, would it not make sense to make
> 
> this part of the bulk-request? In other words don't store the data to
> 
> begin with. What I'm thinking of is something more towards the
> 
> Field.Store.NO property (of Lucene) that I can set for every field
> 
> separately. I'd like to do this programmatically as well, i.e. not
> 
> with JSON commands if I don't have to.
> 
> Thanks for the effort.
> 
> On Feb 9, 11:31 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:
> 
> Hi Thinus,
> 
> Try using updateSettings on the IndicesAdminClient with the relevant  
> settings.
> 
> --
> 
> Ivan
> 
> On Thu, Feb 9, 2012 at 8:38 AM, Thinus Prinsloo
> 
> [thinus.prins...@gmail.com](mailto:thinus.prins...@gmail.com) wrote:
> 
> I would like to disable saving the source with the indexes, but do it
> 
> through the Java API. I believe the method to do it with JSON would
> 
> be to use the "\_source" : {"enabled" : false} idea with the field, but
> 
> I do not know how to do this with the API. Thank you!

---

<div class="post-metadata">

**Author:** ![elfreyshira](https://avatars.discourse-cdn.com/v4/letter/e/47e85d/32.png) [@elfreyshira](https://discuss.elastic.co/u/elfreyshira)\
**Post date:** [July 24, 2012, 10:57pm UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/12 "2012-07-24T22:57:22Z")

</div>

David and Igor,

Thank you very much for your help. Once I've prepared the putmapping, what do I do with the _pmrb_ variable? I want to index a new item after disabling the source.

I've posted my question in more detail here: [http://elasticsearch-users.115913.n3.nabble.com/I-want-to-disable-the-source-with-Java-API-for-a-pre-existing-index-before-setting-a-new-ID-tc4020786.html](http://elasticsearch-users.115913.n3.nabble.com/I-want-to-disable-the-source-with-Java-API-for-a-pre-existing-index-before-setting-a-new-ID-tc4020786.html)

Again, thank you for your help!

- Elfrey

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [July 25, 2012, 12:04am UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/13 "2012-07-25T00:04:01Z")

</div>

There is not much to do with pmrb. You can make sure that your request  
was acknowledge by checking pmrb.acknowledged() is true, but that's pretty  
much it. But after the putMapping call you can go ahead and index your  
record.

On Tuesday, July 24, 2012 6:57:22 PM UTC-4, elfreyshira wrote:

> David and Igor,
> 
> Thank you very much for your help. Once I've prepared the putmapping, what  
> do I do with the /pmrb/ variable? I want to index a new item after  
> disabling  
> the source.
> 
> I've posted my question in more detail here:
> 
> [http://elasticsearch-users.115913.n3.nabble.com/I-want-to-disable-the-source-with-Java-API-for-a-pre-existing-index-before-setting-a-new-ID-tc4020786.html](http://elasticsearch-users.115913.n3.nabble.com/I-want-to-disable-the-source-with-Java-API-for-a-pre-existing-index-before-setting-a-new-ID-tc4020786.html)
> 
> [http://elasticsearch-users.115913.n3.nabble.com/I-want-to-disable-the-source-with-Java-API-for-a-pre-existing-index-before-setting-a-new-ID-tc4020786.html](http://elasticsearch-users.115913.n3.nabble.com/I-want-to-disable-the-source-with-Java-API-for-a-pre-existing-index-before-setting-a-new-ID-tc4020786.html)
> 
> Again, thank you for your help!
> 
> - Elfrey
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Java-API-to-disable-source-tp3730001p4020795.html](http://elasticsearch-users.115913.n3.nabble.com/Java-API-to-disable-source-tp3730001p4020795.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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:19am UTC](https://discuss.elastic.co/t/java-api-to-disable-source/6660/14 "2017-07-06T03:19:10Z")

</div>


