# Using the Updated Jest Client 0.1.1 for Querying ES 1.2 based on Fileds

**URL:** <https://discuss.elastic.co/t/using-the-updated-jest-client-0-1-1-for-querying-es-1-2-based-on-fileds/18458>\
**Category:** Elasticsearch\
**Created:** [July 3, 2014, 9:28am UTC](https://discuss.elastic.co/t/using-the-updated-jest-client-0-1-1-for-querying-es-1-2-based-on-fileds/18458 "2014-07-03T09:28:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kamdar\_mufaddal](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@kamdar\_mufaddal](https://discuss.elastic.co/u/kamdar_mufaddal)\
**Post date:** [July 3, 2014, 9:28am UTC](https://discuss.elastic.co/t/using-the-updated-jest-client-0-1-1-for-querying-es-1-2-based-on-fileds/18458/1 "2014-07-03T09:28:50Z")

</div>

Hi,

I was using Jest client 0.0.5 for conecting and serching the ES indexes.  
Not Elastic Search version was upgraded to 1.2, so I started seeing some  
issues.

I was adding Fields to the query and i could see that the fields that were  
returning me scalar started returning me Array.Previous version of ES was  
giving me correct outpout.

_Query:_  
{  
"from" : 1,  
"size" : 3,  
"query" : {  
"bool" : {  
"must" : {  
"terms" : {  
"id" : ["a10094", "a10087"]  
}  
}  
}  
},  
"fields" : ["account", "PN", "AcctNo"]  
}

_Previous Response:_

{  
AcctNo=A100896151,  
PN=1697951,  
account=NINTERNATIONAL,  
}

_Response After Elastic Search Upgrade:_

{  
AcctNo=_[_  
A100896151  
_]_,  
PN=_[_  
1697951  
_]_,  
account=_[_  
NINTERNATIONAL  
_]_  
}

I read the Documentation that we should use source instead of Fields in the  
query to get correct output.  
So I upgraded my Jest client from io.searchbox.Jest 0.0.5--\>0.1.1.

Below is the code how I create my Jest Client in java.

public static void searchES()  
{  
JestClient client=null;  
HttpClientConfig clientConfig=null;  
/\*

- Creating Config for JestClient  
_/  
String[] urls = VO.getUrl().split(",");  
clientConfig = new  
HttpClientConfig.Builder(Arrays.asList(urls)).multiThreaded(true).build();  
/_

- Creating JEST client instance for Factory  
\*/  
JestClientFactory factory = new JestClientFactory();  
factory.setHttpClientConfig(clientConfig);  
client = factory.getObject();

query="{"from":1,"size":3,"query":{"bool":{"must":{"terms":{"id":["a10094","a10087"]}}}},"fields":["account","PN","AcctNo"]}";  
/\*  
\* Creating SearchSourceBuilder  
\*/  
SearchSourceBuilder searchSourceBuilder = new  
SearchSourceBuilder();  
_searchSourceBuilder.fields(new String ["account", "PN", "AcctNo"] );_  
searchSourceBuilder.query(query);  
searchSourceBuilder.size(CPSConstants.ES\_DATA\_SIZE);

Search search =  
new  
Search.Builder(searchSourceBuilder.toString()).addIndex("esindex").build();  
//Call Elastic Search  
JestResult response = client.execute(search);  
}

I dont know how to add\* \_source\* to _Search_ or _Client_ in java code  
instead of Fields.

Please help.

Regards,  
Mufaddal

--  
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/05dd3548-3928-4cc0-af81-41f05adec94f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/05dd3548-3928-4cc0-af81-41f05adec94f%40googlegroups.com).  
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:18am UTC](https://discuss.elastic.co/t/using-the-updated-jest-client-0-1-1-for-querying-es-1-2-based-on-fileds/18458/2 "2017-07-06T01:18:11Z")

</div>

Closed on July 6, 2017, 1:18am UTC


