[SOLVED] Java ES set addFields fetch the result is null

hello ,I use the search API,just want to get some fileds and set the addFields method.like this,
but when I get the result that is null.
for(SearchHit hit:response.getHits().getHits()){
Map<String, Object> hitsMap = hit.getSource();
log.info("[ "+hitsMap+" ]");
I try to set the setSearchType(SearchType.QUERY_AND_FETCH) method ,or set the QUERY_THEN_FETCH ....but it does not work.

How did you solve it?

Actually I ignore something. When we set the addFields method,we can't fetch the result use that kind of method. It should be like this.

for(SearchHit hit:response.getHits().getHits()){
if( null != fields ){
Set<Entry<String, SearchHitField>> fieldEntry = hit.getFields().entrySet();
JSONObject json = new JSONObject();
for(Entry<String, SearchHitField> entry:fieldEntry){
json.put(entry.getValue().getName(), entry.getValue().getValue());
log.info("[ "+json+" ]");