# I can't use setSource(String) this method with ES 5.6

**URL:** <https://discuss.elastic.co/t/i-cant-use-setsource-string-this-method-with-es-5-6/106996>\
**Category:** Elasticsearch\
**Created:** [November 9, 2017, 9:01am UTC](https://discuss.elastic.co/t/i-cant-use-setsource-string-this-method-with-es-5-6/106996 "2017-11-09T09:01:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GygesM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gygesm/32/52823_2.png) [@GygesM](https://discuss.elastic.co/u/GygesM)\
**Post date:** [November 9, 2017, 9:01am UTC](https://discuss.elastic.co/t/i-cant-use-setsource-string-this-method-with-es-5-6/106996/1 "2017-11-09T09:01:51Z")

</div>

Hi  
when i upgrade my ES from 1.7 to ES 5.6, i can't use this setSource(String) method anymore, please tell me . what kind of method i can use it in order to make my service alive again.  
thanx  
. ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/d/4da30a90e878d0781e6507c21219d64948b19e3d.png)  
this is a old method i can't use. what is it replaced by?

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [November 17, 2017, 9:11am UTC](https://discuss.elastic.co/t/i-cant-use-setsource-string-this-method-with-es-5-6/106996/2 "2017-11-17T09:11:01Z")

</div>

Hi,  
you cannot set the source directly anymore, you need to use a SearchSourceBuilder instead. That will give you a lot of convenience methods for building your search request (like adding queries via QueryBuilder) etc... Creating the SearchSourceBuilder from a String (e.g. Json) directly would require some sort of parsing, which can be done but should probably be avoided since it requires you to have access to a few internal registries to do the parsing. Hope this helps a bit.

---

<div class="post-metadata">

**Author:** ![GygesM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gygesm/32/52823_2.png) [@GygesM](https://discuss.elastic.co/u/GygesM)\
**Post date:** [November 22, 2017, 7:36am UTC](https://discuss.elastic.co/t/i-cant-use-setsource-string-this-method-with-es-5-6/106996/3 "2017-11-22T07:36:40Z")

</div>

thanx a lot, i fixed this problem already.😁😁

---

<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:** [December 20, 2017, 7:36am UTC](https://discuss.elastic.co/t/i-cant-use-setsource-string-this-method-with-es-5-6/106996/4 "2017-12-20T07:36:45Z")

</div>

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