Skip to content

Instantly share code, notes, and snippets.

@parasb
Created March 13, 2015 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parasb/751baf0fca2a7682a8d1 to your computer and use it in GitHub Desktop.
Save parasb/751baf0fca2a7682a8d1 to your computer and use it in GitHub Desktop.
code snipp
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*"
}
},
"filter": {
"bool": {
"should": [
{
"fquery": {
"query": {
"query_string": {
"query": "\"357539019562335\""
}
},
"_cache": true
}
},
{
"fquery": {
"query": {
"query_string": {
"query": "\"357539019562624\""
}
},
"_cache": true
}
}
],
"must": [
{
"fquery": {
"query": {
"query_string": {
"query": "SMSATTEMPTSMO + SMSATTEMPTSMT"
}
},
"_cache": true
}
},
{
"range": {
"@timestamp": {
"to": "2015-03-05T00:00-05:00",
"from": "2015-03-04T00:00-05:00"
}
}
}
]
}
}
}
},
"aggs": {
"events_by_IMEI": {
"terms": {
"field": "IMEI"
},
"aggs": {
"sms_over_time": {
"date_histogram": {
"field": "@timestamp",
"interval": "1h",
"post_zone": "-05:00",
"min_doc_count": 0,
"extended_bounds": {
"min": "2015-03-04T00:00-05:00",
"max": "2015-03-05T00:00-05:00"
}
},
"aggs": {
"total_sms": {
"sum": {
"field": "value"
}
}
}
}
}
}
},
"size": 0
}
{
"took": 9279,
"timed_out": false,
"_shards": {
"total": 20,
"successful": 20,
"failed": 0
},
"hits": {
"total": 354,
"max_score": 0,
"hits": []
},
"aggregations": {
"events_by_IMEI": {
"buckets": [
{
"key": "357539019562624",
"doc_count": 178,
"sms_over_time": {
"buckets": [
{
"key_as_string": "2015-03-04T00:00:00.000Z",
"key": 1425427200000,
"doc_count": 0,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T01:00:00.000Z",
"key": 1425430800000,
"doc_count": 0,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T02:00:00.000Z",
"key": 1425434400000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T03:00:00.000Z",
"key": 1425438000000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T04:00:00.000Z",
"key": 1425441600000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T05:00:00.000Z",
"key": 1425445200000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T06:00:00.000Z",
"key": 1425448800000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T07:00:00.000Z",
"key": 1425452400000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T08:00:00.000Z",
"key": 1425456000000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T09:00:00.000Z",
"key": 1425459600000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T10:00:00.000Z",
"key": 1425463200000,
"doc_count": 8,
"total_sms": {
"value": 1
}
},
{
"key_as_string": "2015-03-04T11:00:00.000Z",
"key": 1425466800000,
"doc_count": 8,
"total_sms": {
"value": 8
}
},
{
"key_as_string": "2015-03-04T12:00:00.000Z",
"key": 1425470400000,
"doc_count": 8,
"total_sms": {
"value": 3
}
},
{
"key_as_string": "2015-03-04T13:00:00.000Z",
"key": 1425474000000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T14:00:00.000Z",
"key": 1425477600000,
"doc_count": 8,
"total_sms": {
"value": 2
}
},
{
"key_as_string": "2015-03-04T15:00:00.000Z",
"key": 1425481200000,
"doc_count": 8,
"total_sms": {
"value": 1
}
},
{
"key_as_string": "2015-03-04T16:00:00.000Z",
"key": 1425484800000,
"doc_count": 8,
"total_sms": {
"value": 4
}
},
{
"key_as_string": "2015-03-04T17:00:00.000Z",
"key": 1425488400000,
"doc_count": 8,
"total_sms": {
"value": 1
}
},
{
"key_as_string": "2015-03-04T18:00:00.000Z",
"key": 1425492000000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T19:00:00.000Z",
"key": 1425495600000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T20:00:00.000Z",
"key": 1425499200000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T21:00:00.000Z",
"key": 1425502800000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T22:00:00.000Z",
"key": 1425506400000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T23:00:00.000Z",
"key": 1425510000000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-05T00:00:00.000Z",
"key": 1425513600000,
"doc_count": 2,
"total_sms": {
"value": 0
}
}
]
}
},
{
"key": "357539019562335",
"doc_count": 176,
"sms_over_time": {
"buckets": [
{
"key_as_string": "2015-03-04T00:00:00.000Z",
"key": 1425427200000,
"doc_count": 0,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T01:00:00.000Z",
"key": 1425430800000,
"doc_count": 0,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T02:00:00.000Z",
"key": 1425434400000,
"doc_count": 6,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T03:00:00.000Z",
"key": 1425438000000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T04:00:00.000Z",
"key": 1425441600000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T05:00:00.000Z",
"key": 1425445200000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T06:00:00.000Z",
"key": 1425448800000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T07:00:00.000Z",
"key": 1425452400000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T08:00:00.000Z",
"key": 1425456000000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T09:00:00.000Z",
"key": 1425459600000,
"doc_count": 8,
"total_sms": {
"value": 3
}
},
{
"key_as_string": "2015-03-04T10:00:00.000Z",
"key": 1425463200000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T11:00:00.000Z",
"key": 1425466800000,
"doc_count": 8,
"total_sms": {
"value": 1
}
},
{
"key_as_string": "2015-03-04T12:00:00.000Z",
"key": 1425470400000,
"doc_count": 8,
"total_sms": {
"value": 4
}
},
{
"key_as_string": "2015-03-04T13:00:00.000Z",
"key": 1425474000000,
"doc_count": 8,
"total_sms": {
"value": 3
}
},
{
"key_as_string": "2015-03-04T14:00:00.000Z",
"key": 1425477600000,
"doc_count": 8,
"total_sms": {
"value": 4
}
},
{
"key_as_string": "2015-03-04T15:00:00.000Z",
"key": 1425481200000,
"doc_count": 8,
"total_sms": {
"value": 10
}
},
{
"key_as_string": "2015-03-04T16:00:00.000Z",
"key": 1425484800000,
"doc_count": 8,
"total_sms": {
"value": 1
}
},
{
"key_as_string": "2015-03-04T17:00:00.000Z",
"key": 1425488400000,
"doc_count": 8,
"total_sms": {
"value": 4
}
},
{
"key_as_string": "2015-03-04T18:00:00.000Z",
"key": 1425492000000,
"doc_count": 8,
"total_sms": {
"value": 2
}
},
{
"key_as_string": "2015-03-04T19:00:00.000Z",
"key": 1425495600000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T20:00:00.000Z",
"key": 1425499200000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T21:00:00.000Z",
"key": 1425502800000,
"doc_count": 8,
"total_sms": {
"value": 1
}
},
{
"key_as_string": "2015-03-04T22:00:00.000Z",
"key": 1425506400000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-04T23:00:00.000Z",
"key": 1425510000000,
"doc_count": 8,
"total_sms": {
"value": 0
}
},
{
"key_as_string": "2015-03-05T00:00:00.000Z",
"key": 1425513600000,
"doc_count": 2,
"total_sms": {
"value": 0
}
}
]
}
}
]
}
}
}
{
"facets": {
"0": {
"facet_filter": {
"fquery": {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*"
}
},
"filter": {
"bool": {
"should": [
{
"fquery": {
"query": {
"query_string": {
"query": "\"357539019562335\""
}
},
"_cache": true
}
},
{
"fquery": {
"query": {
"query_string": {
"query": "\"357539019558374\""
}
},
"_cache": true
}
}
],
"must": [
{
"fquery": {
"query": {
"query_string": {
"query": "AMRCALLSDURATION"
}
},
"_cache": true
}
},
{
"range": {
"@timestamp": {
"to": 1425618000000,
"from": 1425528000000
}
}
}
]
}
}
}
}
}
},
"date_histogram": {
"key_field": "@timestamp",
"interval": "1h",
"value_field": "value"
},
"global": true
},
"1": {
"facet_filter": {
"fquery": {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*"
}
},
"filter": {
"bool": {
"should": [
{
"fquery": {
"query": {
"query_string": {
"query": "\"357539019562624\""
}
},
"_cache": true
}
}
],
"must": [
{
"fquery": {
"query": {
"query_string": {
"query": "AMRCALLSDURATION"
}
},
"_cache": true
}
},
{
"range": {
"@timestamp": {
"to": 1425618000000,
"from": 1425528000000
}
}
}
]
}
}
}
}
}
},
"date_histogram": {
"key_field": "@timestamp",
"interval": "1h",
"value_field": "value"
},
"global": true
}
},
"size": 0
}
{
"took": 389,
"timed_out": false,
"_shards": {
"total": 10,
"successful": 10,
"failed": 0
},
"hits": {
"total": 371712,
"max_score": 0,
"hits": []
},
"facets": {
"0": {
"_type": "date_histogram",
"entries": [
{
"time": 1425528000000,
"count": 8,
"min": 17929,
"max": 41193,
"total": 236488,
"total_count": 8,
"mean": 29561
},
{
"time": 1425531600000,
"count": 8,
"min": 17929,
"max": 41193,
"total": 236488,
"total_count": 8,
"mean": 29561
},
{
"time": 1425535200000,
"count": 8,
"min": 17929,
"max": 41193,
"total": 236488,
"total_count": 8,
"mean": 29561
},
{
"time": 1425538800000,
"count": 8,
"min": 17929,
"max": 41193,
"total": 236488,
"total_count": 8,
"mean": 29561
},
{
"time": 1425542400000,
"count": 8,
"min": 17929,
"max": 41193,
"total": 236488,
"total_count": 8,
"mean": 29561
},
{
"time": 1425546000000,
"count": 8,
"min": 17929,
"max": 41193,
"total": 236488,
"total_count": 8,
"mean": 29561
},
{
"time": 1425549600000,
"count": 10,
"min": 0,
"max": 41193,
"total": 236492,
"total_count": 10,
"mean": 23649.2
},
{
"time": 1425553200000,
"count": 8,
"min": 17929,
"max": 41193,
"total": 236488,
"total_count": 8,
"mean": 29561
},
{
"time": 1425556800000,
"count": 8,
"min": 17929,
"max": 41193,
"total": 236488,
"total_count": 8,
"mean": 29561
},
{
"time": 1425560400000,
"count": 8,
"min": 17929,
"max": 41193,
"total": 236488,
"total_count": 8,
"mean": 29561
},
{
"time": 1425564000000,
"count": 8,
"min": 17929,
"max": 41193,
"total": 236488,
"total_count": 8,
"mean": 29561
},
{
"time": 1425567600000,
"count": 8,
"min": 17929,
"max": 41513,
"total": 237147,
"total_count": 8,
"mean": 29643.375
},
{
"time": 1425571200000,
"count": 8,
"min": 18090,
"max": 41864,
"total": 239977,
"total_count": 8,
"mean": 29997.125
},
{
"time": 1425574800000,
"count": 8,
"min": 18496,
"max": 42992,
"total": 244239,
"total_count": 8,
"mean": 30529.875
},
{
"time": 1425578400000,
"count": 8,
"min": 19358,
"max": 44515,
"total": 253306,
"total_count": 8,
"mean": 31663.25
},
{
"time": 1425582000000,
"count": 8,
"min": 20249,
"max": 46579,
"total": 264178,
"total_count": 8,
"mean": 33022.25
},
{
"time": 1425585600000,
"count": 8,
"min": 20639,
"max": 48679,
"total": 275790,
"total_count": 8,
"mean": 34473.75
},
{
"time": 1425589200000,
"count": 8,
"min": 20980,
"max": 48828,
"total": 279312,
"total_count": 8,
"mean": 34914
},
{
"time": 1425592800000,
"count": 8,
"min": 0,
"max": 49274,
"total": 72744,
"total_count": 8,
"mean": 9093
},
{
"time": 1425596400000,
"count": 8,
"min": 640,
"max": 2186,
"total": 8330,
"total_count": 8,
"mean": 1041.25
},
{
"time": 1425600000000,
"count": 8,
"min": 1121,
"max": 6066,
"total": 20217,
"total_count": 8,
"mean": 2527.125
},
{
"time": 1425603600000,
"count": 8,
"min": 2306,
"max": 10035,
"total": 43722,
"total_count": 8,
"mean": 5465.25
},
{
"time": 1425607200000,
"count": 8,
"min": 2517,
"max": 10080,
"total": 50402,
"total_count": 8,
"mean": 6300.25
},
{
"time": 1425610800000,
"count": 8,
"min": 2569,
"max": 10103,
"total": 50688,
"total_count": 8,
"mean": 6336
},
{
"time": 1425614400000,
"count": 8,
"min": 2569,
"max": 10103,
"total": 50688,
"total_count": 8,
"mean": 6336
},
{
"time": 1425618000000,
"count": 2,
"min": 2569,
"max": 10103,
"total": 12672,
"total_count": 2,
"mean": 6336
}
]
},
"1": {
"_type": "date_histogram",
"entries": [
{
"time": 1425528000000,
"count": 4,
"min": 31365,
"max": 31365,
"total": 125460,
"total_count": 4,
"mean": 31365
},
{
"time": 1425531600000,
"count": 4,
"min": 31365,
"max": 31365,
"total": 125460,
"total_count": 4,
"mean": 31365
},
{
"time": 1425535200000,
"count": 4,
"min": 31365,
"max": 31365,
"total": 125460,
"total_count": 4,
"mean": 31365
},
{
"time": 1425538800000,
"count": 4,
"min": 31365,
"max": 31365,
"total": 125460,
"total_count": 4,
"mean": 31365
},
{
"time": 1425542400000,
"count": 4,
"min": 31365,
"max": 31365,
"total": 125460,
"total_count": 4,
"mean": 31365
},
{
"time": 1425546000000,
"count": 4,
"min": 31365,
"max": 31365,
"total": 125460,
"total_count": 4,
"mean": 31365
},
{
"time": 1425549600000,
"count": 5,
"min": 54,
"max": 31365,
"total": 125514,
"total_count": 5,
"mean": 25102.8
},
{
"time": 1425553200000,
"count": 4,
"min": 31365,
"max": 31365,
"total": 125460,
"total_count": 4,
"mean": 31365
},
{
"time": 1425556800000,
"count": 4,
"min": 31365,
"max": 31365,
"total": 125460,
"total_count": 4,
"mean": 31365
},
{
"time": 1425560400000,
"count": 4,
"min": 31365,
"max": 31369,
"total": 125468,
"total_count": 4,
"mean": 31367
},
{
"time": 1425564000000,
"count": 4,
"min": 31369,
"max": 31403,
"total": 125544,
"total_count": 4,
"mean": 31386
},
{
"time": 1425567600000,
"count": 4,
"min": 31403,
"max": 31602,
"total": 126193,
"total_count": 4,
"mean": 31548.25
},
{
"time": 1425571200000,
"count": 4,
"min": 31652,
"max": 32572,
"total": 128430,
"total_count": 4,
"mean": 32107.5
},
{
"time": 1425574800000,
"count": 4,
"min": 32572,
"max": 34366,
"total": 134647,
"total_count": 4,
"mean": 33661.75
},
{
"time": 1425578400000,
"count": 4,
"min": 34962,
"max": 35405,
"total": 140702,
"total_count": 4,
"mean": 35175.5
},
{
"time": 1425582000000,
"count": 4,
"min": 35510,
"max": 36011,
"total": 142694,
"total_count": 4,
"mean": 35673.5
},
{
"time": 1425585600000,
"count": 4,
"min": 36011,
"max": 36087,
"total": 144221,
"total_count": 4,
"mean": 36055.25
},
{
"time": 1425589200000,
"count": 4,
"min": 36087,
"max": 36602,
"total": 145329,
"total_count": 4,
"mean": 36332.25
},
{
"time": 1425592800000,
"count": 4,
"min": 0,
"max": 36956,
"total": 39069,
"total_count": 4,
"mean": 9767.25
},
{
"time": 1425596400000,
"count": 4,
"min": 1067,
"max": 1163,
"total": 4451,
"total_count": 4,
"mean": 1112.75
},
{
"time": 1425600000000,
"count": 4,
"min": 1417,
"max": 2002,
"total": 6673,
"total_count": 4,
"mean": 1668.25
},
{
"time": 1425603600000,
"count": 4,
"min": 2147,
"max": 2728,
"total": 10331,
"total_count": 4,
"mean": 2582.75
},
{
"time": 1425607200000,
"count": 4,
"min": 2728,
"max": 2728,
"total": 10912,
"total_count": 4,
"mean": 2728
},
{
"time": 1425610800000,
"count": 4,
"min": 2728,
"max": 2728,
"total": 10912,
"total_count": 4,
"mean": 2728
},
{
"time": 1425614400000,
"count": 4,
"min": 2728,
"max": 2728,
"total": 10912,
"total_count": 4,
"mean": 2728
},
{
"time": 1425618000000,
"count": 1,
"min": 2728,
"max": 2728,
"total": 2728,
"total_count": 1,
"mean": 2728
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment