Please help me to es query I have store data in es as
{
"i": [
{
"ap": "com.touchtype.swiftkey",
"t": "1507284964"
},
{
"ap": "com.sly.sangam.mediametadatareader",
"t": "1506398555"
},
{
"ap": "com.flipkart.android",
"t": "1505733513"
},
{
"ap": "com.google.android.apps.inputmethod.hindi",
"t": "1507284964"
},
{
"ap": "com.mfashiongallery.emag",
"t": "1505733231"
},
{
"ap": "com.google.android.instantapps.supervisor",
"t": "1505734613"
},
{
"ap": "com.duokan.phone.remotecontroller",
"t": "1505733237"
},
{
"ap": "com.zingtillion",
"t": "1507284921"
},
{
"ap": "com.miui.klo.bugreport",
"t": "1507284964"
},
{
"ap": "com.zing.ultronone",
"t": "1505982478"
},
{
"ap": "com.swiftkey.swiftkeyconfigurator",
"t": "1507284964"
},
{
"ap": "com.facebook.katana",
"t": "1507284964"
},
{
"ap": "com.mi.global.shop",
"t": "1505733219"
},
{
"ap": "com.swiftkey.languageprovider",
"t": "1507284964"
},
{
"ap": "cn.wps.moffice_eng",
"t": "1505733250"
}
],
"id": "1171533212255571",
"dt": "2017-10-06T18:16:04"
}
Now try to fetch hourly count but getting equal count(15) in each bucket, i need only those count related to that date (i.t)
"size": 0,
"aggs": {
"final_bucket": {
"filter": {
"term": {
"zid": "1171533212255571"
}
},
"aggs": {
"group_by_field1": {
"date_histogram": {
"field": "i.t",
"interval": "hour",
"min_doc_count": 1,
"format": "yyyy-MM-dd hh:mm a",
"order" : { "_key" : "asc" }
},
"aggs": {
"field_count": {
"cardinality": {
"field": "i.ap"
}
}
}
}
}
}
}
===================Output=============================
"aggregations": {
"final_bucket": {
"doc_count": 1,
"group_by_field1": {
"buckets": [
{
"key_as_string": "2017-09-18 11:00 AM",
"key": 1505732400000,
"doc_count": 1,
"field_count": {
"value": 15
}
},
{
"key_as_string": "2017-09-21 08:00 AM",
"key": 1505980800000,
"doc_count": 1,
"field_count": {
"value": 15
}
},
{
"key_as_string": "2017-09-26 04:00 AM",
"key": 1506398400000,
"doc_count": 1,
"field_count": {
"value": 15
}
},
{
"key_as_string": "2017-10-06 10:00 AM",
"key": 1507284000000,
"doc_count": 1,
"field_count": {
"value": 15
}
}
]
}
}
}
}