-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetZXVersionCount.py
More file actions
83 lines (74 loc) · 1.74 KB
/
GetZXVersionCount.py
File metadata and controls
83 lines (74 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/evn python
# -*- coding: UTF-8 -*-
from datetime import datetime
from datetime import timedelta
from elasticsearch import Elasticsearch
import pytz
import pandas as pd
import DateGenerator
def search_es(es):
body = {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*",
"operator": "and"
}
},
"filter": {
"bool": {
"must": [
{
"query": {
"query_string": {
"query": "iphone",
"operator": "and"
}
}
},
{
"query": {
"query_string": {
"operator": "and",
"query": "*"
}
}
}
],
"must_not": []
}
}
}
},
"size": 10,
"aggs": {
"2": {
"terms": {
"field": "versionName",
"size": 1000,
"order": {
"_count": "desc"
}
}
}
}
}
result = es.search(index='statistics-user*', body=body,size = 10)
return result
def analyse(buckets):
'''
构建data frame
'''
data = []
for item in buckets:
data.append(item['doc_count'])
return data
def get_count_of_last_week():
# start_date, end_date = DateGenerator.generate_date()
es = Elasticsearch(['http://app.publish.youni.im:9200/'])
result = search_es(es)
#buckets = result['aggregations'][DATE_AGG]['buckets']
#result = analyse(buckets)
return result
get_count_of_last_week()