Nested aggregation problem


(Thamizharasu) #1

I am facing some problem with nested Aggregation. I am NOT able to get any aggregation result. I have added my JSON index values and aggregation query. Please help me to resolve this problem.

JSON output:
{
"took": 1,
"timed_out": false,
"_shards":
{
"total": 5,
"successful": 5,
"failed": 0
},
"hits":
{
"total": 1,
"max_score": 1,
"hits":
[
{
"_index": "talks",
"_type": "ftype",
"_id": "84d81284-ceaf-408d-8fe4-3bd3a633e5db",
"_score": 1,
"_source":
{
"id": "84d81284-ceaf-408d-8fe4-3bd3a633e5db",
"questId": "7da5a2f4-052a-4d09-befb-a657b39bc4fc",
"user":
{
"id": "cf61d4ac-0374-4cac-a4df-e504b7c18868",
"name": "Roger",
"email": "roger@gmail.com",
"mobile": null,
"dob": null
},
"opinions":
[
{
"title": "Do you like our service?",
"labels":
[
"service"
],
"rating": "OK"
},
{
"title": "Do you refer to your friend?",
"labels":
[
"reference"
],
"rating": "OK"
},
{
"title": "Do you like our ambiance?",
"labels":
[
"ambiance"
],
"rating": "NO"
}
],
"date": null
}
}
]
}
}

Aggregation query:
{
"aggs" : {
"ratings" : {
"terms" : {
"field" : "opinions.rating"
}
}
}
}

Aggregation result:
{
"took": 110,
"timed_out": false,
"_shards":
{
"total": 5,
"successful": 5,
"failed": 0
},
"hits":
{
"total": 1,
"max_score": 0,
"hits":
[
]
},
"aggregations":
{
"ratings":
{
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets":
[
{
"key": "no",
"doc_count": 1
},
{
"key": "ok",
"doc_count": 1
}
]
}
}
}

Even I changed my query with "nested" type, I am NOT able to get any result. Please help me...


(Thamizharasu) #2

I solved the problem by changing the mapping configuration with proper sub type.


(system) #3