Hi There,
Could someone help to get it working?
So far I got the solution below. This works for simple queries, however it doesn't work for aggregations and I am getting exception ParsingException "Could not parse aggregation keyed as [dashboard]"
JsonXContentParser xContentParser = new JsonXContentParser(NamedXContentRegistry.EMPTY,
new JsonFactory().createParser(SearchResponse response = SearchResponse.fromXContent(xContentParser);
The response I need to parse is provided below:
{
"took": 16,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 1,
"hits": [
{
"_index": "demo",
"_type": "demo",
"_id": "OSScKmIBKBDaRuGPyr42",
"_score": 1,
"_source": {
"demoId": "2",
"demoName": "j",
"uniqueDemo": "jab1980xy11b"
}
},
{
"_index": "demo",
"_type": "demo",
"_id": "OCScKmIBKBDaRuGPyr42",
"_score": 1,
"_source": {
"demoId": "2",
"demoName": "j",
"uniqueDemo": "jmb1970oi611234554321123a"
}
}
]
},
"aggregations": {
"dashboard": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "jab1980xy11b",
"doc_count": 1,
"data": {
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "demo",
"_type": "demo",
"_id": "OSScKmIBKBDaRuGPyr42",
"_score": 1,
"_source": {
"demoId": "2",
"demoName": "j"
}
}
]
}
}
},
{
"key": "jmb1970oi611234554321123a",
"doc_count": 1,
"data": {
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "demo",
"_type": "demo",
"_id": "OCScKmIBKBDaRuGPyr42",
"_score": 1,
"_source": {
"demoId": "2",
"demoName": "j"
}
}
]
}
}
}
]
}
}
}