# addField(java.lang.String) deprecated in ES v5.6.2

**URL:** <https://discuss.elastic.co/t/addfield-java-lang-string-deprecated-in-es-v5-6-2/189473>\
**Category:** Elasticsearch\
**Created:** [July 9, 2019, 7:37am UTC](https://discuss.elastic.co/t/addfield-java-lang-string-deprecated-in-es-v5-6-2/189473 "2019-07-09T07:37:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![utkarsh](https://avatars.discourse-cdn.com/v4/letter/u/e9bcb4/32.png) [@utkarsh](https://discuss.elastic.co/u/utkarsh)\
**Post date:** [July 9, 2019, 7:37am UTC](https://discuss.elastic.co/t/addfield-java-lang-string-deprecated-in-es-v5-6-2/189473/1 "2019-07-09T07:37:22Z")

</div>

I am upgrading the java api's in favour of es v5.6.2. The code earlier used addField method on SearchRequestBuilder, by passing the field that were to be returned in the method argument. Now, this method been deprecated, so I replaced it with addStoredField. This approach didn't seems to work as the SearchResponse does not have these fields, when calling execute().actionGet() on SearchRequestBuilder .  
In the query, the "fields"(es v2.3.3) has changed to "stored\_fields"(es v5.6.2) due to addField() being replaced by addStoredField().  
However, I haven't set the "store" field as true in the mapping which is being used in the Re-indexing utility, as I can't figure out which way can this issue be resolved.  
Please help 😟

---

<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 9, 2019, 9:06am UTC](https://discuss.elastic.co/t/addfield-java-lang-string-deprecated-in-es-v5-6-2/189473/2 "2019-07-09T09:06:52Z")

</div>

It means that you need to use source filtering then. See [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html)

---

<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:** [August 6, 2019, 9:07am UTC](https://discuss.elastic.co/t/addfield-java-lang-string-deprecated-in-es-v5-6-2/189473/3 "2019-08-06T09:07:03Z")

</div>

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