Commit cdde760f authored by lixiaofang's avatar lixiaofang

add

parent 99d7e098
...@@ -47,28 +47,29 @@ class GroupUtils(object): ...@@ -47,28 +47,29 @@ class GroupUtils(object):
return {"total_count": 0, "hits": []} return {"total_count": 0, "hits": []}
@classmethod @classmethod
def get_hot_pictorial_recommend_result_list(cls, offset, size, es_cli_obj=None): def get_hot_pictorial_recommend_result_list(cls,offset,size,es_cli_obj=None):
try: try:
if not es_cli_obj: if not es_cli_obj:
es_cli_obj = ESPerform.get_cli() es_cli_obj = ESPerform.get_cli()
q = dict() q = dict()
q["query"] = { q["query"] = {
"bool": { "bool":{
"must": [ "must":[
{"term": {"is_online": True}}, {"term": {"is_online": True}},
{"term": {"is_deleted": False}} {"term":{"is_deleted": False}},
{"term": {"effective": True}}
] ]
} }
} }
q["sort"] = [ q["sort"] = [
{"high_quality_topic_num": {"order": "desc"}} {"high_quality_topic_num":{"order":"desc"}}
] ]
q["_source"] = { q["_source"] = {
"includes": ["id"] "includes":["id"]
} }
result_dict = ESPerform.get_search_results(es_cli_obj, "pictorial", offset ,size)
result_dict = ESPerform.get_search_results(es_cli_obj,"pictorial",q,offset,size)
pictorial_ids_list = [] pictorial_ids_list = []
if len(result_dict["hits"]) > 0: if len(result_dict["hits"]) > 0:
...@@ -95,26 +96,26 @@ class GroupUtils(object): ...@@ -95,26 +96,26 @@ class GroupUtils(object):
"must": [ "must": [
{"term": {"is_online": True}}, {"term": {"is_online": True}},
{"term": {"user_id": user_id}}, {"term": {"user_id": user_id}},
{"term": {"is_deleted": False}} {"term": {"is_deleted": False}},
{"term":{"effective":True}}
] ]
} }
} }
q["_source"] = { q["_source"] = {
"includes": ["attention_pictorial_id_list"] "includes": ["attention_pictorial_id_list"]
} }
MAX_LOAD = 1000
sizes = max(size, MAX_LOAD)
result_dict = ESPerform.get_search_results(es_cli_obj, "user", q, offset=0, size=sizes) result_dict = ESPerform.get_search_results(es_cli_obj, "user", q, offset, size)
pictorial_ids_list = []
if len(result_dict["hits"]) > 0: if len(result_dict["hits"]) > 0:
pictorial_ids_list = result_dict["hits"][0]["_source"]["attention_pictorial_id_list"] return result_dict["hits"][0]["_source"]["attention_pictorial_id_list"]
else:
return []
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return [] return []
@classmethod @classmethod
def get_pictorial_ids_by_aggs(cls, pictorial_ids_list, es_cli_obj=None): def get_pictorial_ids_by_aggs(cls, pictorial_ids_list, es_cli_obj=None):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment