# \_all and Java API

**URL:** <https://discuss.elastic.co/t/-all-and-java-api/18339>\
**Category:** Elasticsearch\
**Created:** [June 25, 2014, 3:51pm UTC](https://discuss.elastic.co/t/-all-and-java-api/18339 "2014-06-25T15:51:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Dotte](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben_dotte/32/1462_2.png) [@Ben\_Dotte](https://discuss.elastic.co/u/Ben_Dotte)\
**Post date:** [June 25, 2014, 3:51pm UTC](https://discuss.elastic.co/t/-all-and-java-api/18339/1 "2014-06-25T15:51:54Z")

</div>

Hi,

Is there a way to specify which fields to include/exclude from \_all using  
just the Java API? I'm currently indexing data using XContentBuilder (do  
not have separate json mappings) like this:

XContentBuilder builder = jsonBuilder().startObject()  
.field("datefield", new Date())  
.field("astring", "blah")  
.endObject();

I would like to exclude things like dates, numeric fields, etc. Is it  
necessary to create json mappings to have this fine-grained of control?

Thanks,  
Ben

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8bd090af-bfa1-4794-9ea6-852691bc63d0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8bd090af-bfa1-4794-9ea6-852691bc63d0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 25, 2014, 3:54pm UTC](https://discuss.elastic.co/t/-all-and-java-api/18339/2 "2014-06-25T15:54:29Z")

</div>

Yes. You need to define a mapping.

My recommandation would to disable \_all field and use `copy_to` feature which is to me really more flexible.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 25 juin 2014 à 17:51:59, Ben Dotte ([bdotte@widen.com](mailto:bdotte@widen.com)) a écrit:

Hi,

Is there a way to specify which fields to include/exclude from \_all using just the Java API? I'm currently indexing data using XContentBuilder (do not have separate json mappings) like this:

XContentBuilder builder = jsonBuilder().startObject()  
.field("datefield", new Date())  
.field("astring", "blah")  
.endObject();

I would like to exclude things like dates, numeric fields, etc. Is it necessary to create json mappings to have this fine-grained of control?

## Thanks, Ben

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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8bd090af-bfa1-4794-9ea6-852691bc63d0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8bd090af-bfa1-4794-9ea6-852691bc63d0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.53aaf0b5.440badfc.9da9%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.53aaf0b5.440badfc.9da9%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:19am UTC](https://discuss.elastic.co/t/-all-and-java-api/18339/3 "2017-07-06T01:19:45Z")

</div>


