Nested Aggregations filter with the Java


(Akhil) #1

Hi ,

I have an i issue while parsing the elasticsearch response with the aggregations , I am receiving the elastic search response like this :

{
"took" : 93,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 5,
"max_score" : 1.0,
"hits" : [ {
"_index" : "dev_search",
"_type" : "aggregate",
"_id" : "aggregation-search-1",
"_score" : 1.0,
"_source":{"viewed":"false","type":"personal","initializer":"trevor"}
} ]
},
"aggregations" : {
"unreadMessages_count" : {
"doc_count" : 0
}
}
}

Once after i receive this response i am converting to our java object by setting hits and other properties. In the way of conversion i had a trouble of parsing the aggregations. My java object accepts the map<string,aggregation> in which i am setting like this from the ealstic search response :
cesSearchResponse.setAggregations(searchResponse.getAggregations().getAsMap());

once after the aggregations response pulled as a map then it is appending with one more nested aggregation entry under the existing aggregation and the response from ES is not same as through our java object as it is appending with extra entry. Can any one tell me how to remove or ignore or filter that nested one to not to add to existing one ? My goal is to have the ES agg resposne should be same as our client response object ?

Here is the Java client response once after it is converted. The getasmap method is not giving the right key value combination as ES is giving in json. Getasmap is adding the new entry on top of the existing one.

{
"hits":{
"total":5
},
"results":[
{
"ces":{
"record-id":"aggregation-search-1"
}
}
],
"aggregations":{
"unreadMessages_count":{
"name":"unreadMessages_count",
"docCount":0,
"aggregations":{
"asMap":{

        }
     }
  }

}
}

the additional thing which itis popping up is :slight_smile:
"aggregations":{
"asMap":{

        }

which needs to be trimmed. Please help..


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.