I have been using this code for ES 2.3 and it worked fine. I'm query against data already loaded in Elastic search. I'm Unable to do this in ES 5.3. I'm just trying to get values for certain fields from 300 fields loaded into ES. Instead of JSON I want result into "|" delimited. Is there a way to do similar with ES 5.3 ?
for( SearchHit hit : response.getHits())
{
String s0 = hit.field("first_name").getValue().toString();
result.add(s0);
String s1 = hit.field("last_name").getValue().toString();
result.add(s1);
String s2 ="";
if(hit.fields().containsKey("middle_name"))
{
String s2 = hit.field("middle_name").getValue().toString();
result.add(s2);
}
finalresult = s0 + "|" + s1 + "|" + s2;
}