def count_text_num(uid_list, fb_flow_text_index_list): count_result = {} #QQ那边好像就是按照用户来count的 https://github.com/huxiaoqian/xnr1/blob/82ff9704792c84dddc3e2e0f265c46f3233a786f/xnr/qq_xnr_manage/qq_history_count_timer.py for uid in uid_list: textnum_query_body = { 'query': { "filtered": { "filter": { "bool": { "must": [ { "term": { "uid": uid } }, ] } } } } } text_num = 0 for index_name in fb_flow_text_index_list: result = es.count(index=index_name, doc_type=flow_text_index_type, body=textnum_query_body) if result['_shards']['successful'] != 0: text_num += result['count'] count_result[uid] = text_num return count_result
def count_flow_text_num(uid, flow_text_index_list, index_type, search_flag_ch=False): if search_flag_ch: textnum_query_body = { 'query': { "filtered": { "filter": { "bool": { "must": [ { "term": { "uid": uid } }, { "term": { "flag_ch": 1 } }, ] } } } }, } else: textnum_query_body = { 'query': { "filtered": { "filter": { "bool": { "must": [ { "term": { "uid": uid } }, ] } } } }, } text_num = 0 for index_name in flow_text_index_list: result = es.count(index=index_name, doc_type=index_type, body=textnum_query_body) if result['_shards']['successful'] != 0: text_num += result['count'] return text_num
def influence_active(uid, index_name): query_body = {'query': {'term': {'uid': uid}}} #index_name = facebook_flow_text_index_name_pre + ts2datetime(current_time) es_count = es.count(index=index_name, doc_type=facebook_flow_text_index_type, body=query_body) if es_count['_shards']['successful'] != 0: active_num = es_count['count'] else: active_num = 0 return active_num