# Avoid field indexing Java API

**URL:** <https://discuss.elastic.co/t/avoid-field-indexing-java-api/137837>\
**Category:** Elasticsearch\
**Created:** [June 28, 2018, 5:21pm UTC](https://discuss.elastic.co/t/avoid-field-indexing-java-api/137837 "2018-06-28T17:21:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josef\_Fritzer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/josef_fritzer/32/54420_2.png) [@Josef\_Fritzer](https://discuss.elastic.co/u/Josef_Fritzer)\
**Post date:** [June 28, 2018, 5:21pm UTC](https://discuss.elastic.co/t/avoid-field-indexing-java-api/137837/1 "2018-06-28T17:21:12Z")

</div>

Hi guys, I would like to use elastic for data storage, therefore I use the Index Request `new IndexRequest(„myIndex“, „mytype“, „randomId“).source(„myJson“, Xcontent.Json)`. But i have to avoid that the fields of the added doc will be indexed. How do I set the „\_doc“ {enabled:false} Parameter in Java? Thanks

---

<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, 2018, 6:42pm UTC](https://discuss.elastic.co/t/avoid-field-indexing-java-api/137837/2 "2018-06-28T18:42:39Z")

</div>

You do that when creating the index not when indexing documents.

See [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#mappings](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#mappings)

---

<div class="post-metadata">

**Author:** ![Josef\_Fritzer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/josef_fritzer/32/54420_2.png) [@Josef\_Fritzer](https://discuss.elastic.co/u/Josef_Fritzer)\
**Post date:** [June 28, 2018, 7:36pm UTC](https://discuss.elastic.co/t/avoid-field-indexing-java-api/137837/3 "2018-06-28T19:36:54Z")

</div>

Yep you're right, I just found the following in the documentation: [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-create-index.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-create-index.html)

I guess this should work, when creating the index with the CreateIndexRequest

request.mapping("myType",  
"{\n" +  
" "myType": {\n" +  
" "enabled": "false\“\n“  
„}“  
"}",  
XContentType.JSON);

---

<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 26, 2018, 7:36pm UTC](https://discuss.elastic.co/t/avoid-field-indexing-java-api/137837/4 "2018-07-26T19:36:57Z")

</div>

Closed on July 26, 2018, 7:36pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
