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

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();

             String 
    

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/05dd3548-3928-4cc0-af81-41f05adec94f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.