How to displays missed fields all together including “key” and “doc_count” with null values in each bucket values with zero (key and doc_count)


(Kiran S N) #1

This is my query below :

GET article_info/article/_search
{
"fields": [
"media_type"
],
"query": {
"filtered": {
"query": {
"query_string": {
"query": "pdf_url:.pdf"
}
},
"filter": {
"range": {
"mediadate": {
"from": "02-21-2016",
"to": "02-26-2016"
}
}
}
}
},
"size": 0,
"aggs": {
"days": {
"date_histogram": {
"field": "mediadate",
"interval": "day",
"format": "MM-dd-yyyy",
"min_doc_count": 0
},
"aggs": {
"art_count": {
"terms": {
"field": "media_type",
"order": {
"_term": "asc"
}
}
}
}
}
}
}
}

}

results below here:

{
"took": 2,
"timed_out": false,
"_shards": {
"total": 10,
"successful": 10,
"failed": 0
},
"hits": {
"total": 13352,
"max_score": 0,
"hits": []
},
"aggregations": {
"days": {
"buckets": [
{
"key_as_string": "02-21-2016",
"key": 1456012800000,
"doc_count": 12496,
"art_count": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "blog",
"doc_count": 4920
},
{
"key": "media",
"doc_count": 36
},
{
"key": "print",
"doc_count": 101
},
{
"key": "service",
"doc_count": 68
},
{
"key": "social",
"doc_count": 36
},
{
"key": "web",
"doc_count": 7371
},
{
"key": "wire",
"doc_count": 68
}
]
}
},
{
"key_as_string": "02-22-2016",
"key": 1456099200000,
"doc_count": 854,
"art_count": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "blog",
"doc_count": 539
},
{
"key": "service",
"doc_count": 92
},
{
"key": "web",
"doc_count": 223
},
{
"key": "wire",
"doc_count": 92
}
]
}
},
{
"key_as_string": "02-23-2016",
"key": 1456185600000,
"doc_count": 1,
"art_count": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "web",
"doc_count": 1
}
]
}
},
{
"key_as_string": "02-24-2016",
"key": 1456272000000,
"doc_count": 1,
"art_count": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "web",
"doc_count": 1
}
]
}
}
]
}
}
}


(Kiran S N) #2

please help me as soon.........


(system) #3