我要进行映射,以便将一些数据从弹性搜索引擎传递到某个Java对象,使用此SearchHit.getAt(i).getFields();
获取Map<String,SearchHitField>
。
问题是,我得到一张空地图,因此null
上有一个SearchHitField
值(例如adresseField
)。
这是我目前的代码:
SearchResponse response = searchCriteria(client,"001","Actif");
List<EsClient> esClientList = new ArrayList<EsClient>();
// get all Hits of response
SearchHits searchHits = response.getHits();
for(int i=0;i<response.getHits().getTotalHits()-1;i++) {
// get fields of response(hits) (fieldName/value)
Map<String,SearchHitField> responseFields = searchHits.getAt(i).getFields();
// get required field
SearchHitField adresseField = responseFields.get("Complement_adresse");
SearchHitField nomField = responseFields.get("Nom");
SearchHitField prenomField = responseFields.get("Prenom");
SearchHitField libelleQuartierField = responseFields.get("Libille_quartier");
System.out.println(adresseField.getValue());
}
有人可以帮助我吗?提前谢谢。
更新:
响应调试值 searchHist调试值