我一直在ES 2.3中使用此代碼,它工作正常。我正在查詢已經在Elastic搜索中加載的數據。我無法在ES 5.3中執行此操作。我只是想從300個字段加載到ES的某些字段獲取值。我想把結果代入「|」而不是JSON分隔。有沒有類似ES5.3的方法?ElasticSearch 5.3 SearchHit hit.field
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;
}
預先感謝您的幫助
您是否獲得任何異常,而這樣做的ES 5.3? –