Commit 8f630226 authored by lixiaofang's avatar lixiaofang

add query

parent 33ff44e9
...@@ -141,47 +141,46 @@ def pictorial_topic(topic_id=-1, offset=0, size=10): ...@@ -141,47 +141,46 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
if len(pict_pictorial_ids_list) < 10: if len(pict_pictorial_ids_list) < 10:
q["query"] = { q["query"] = {
"bool": { "bool": {
"must":[{ "must": [{
"term": { "term": {
"is_online": True "is_online": True}
}, },
"term": { {"term": {
"is_delete": False "is_delete": False}
}, },
"terms": { {"terms": {
"tag_id": [211302, 195275, 195246, 317175, 274332, 96, 345697, 336486, 473577, 336051, "tag_id": [211302, 195275, 195246, 317175, 274332, 96, 345697, 336486, 473577, 336051,
847034, 482012] 847034, 482012]# topic_tag_list }
# topic_tag_list }}
} ]
}]
} }
} }
q["_source"] = { q["_source"] = {
"include": ["id", "tag_id"] "include": ["id", "tag_id"]
} }
q["sort"] = { q["sort"] = {
'update_time': { 'update_time': {
'order': 'desc' 'order': 'desc'
}
} }
q["form"] = 0
q["size"] = 10
result_dict = ESPerform.get_search_results(es_cli_obj, "pictorial", q, offset, size) }
if len(result_dict["hits"]) > 0: q["form"] = 0
pictorial_id_list.append(item["_source"]["id"] for item in result_dict["hits"]) # q["size"] = 10
logging.info("get result_dict tag:%s" % result_dict) result_dict = ESPerform.get_search_results(es_cli_obj, "pictorial", q, offset, size)
if len(result_dict["hits"]) > 0:
pictorial_id_list.append(item["_source"]["id"] for item in result_dict["hits"]) #
return {"pictorial_ids_list": pictorial_id_list} logging.info("get result_dict tag:%s" % result_dict)
else: return {"pictorial_ids_list": pictorial_id_list}
return {"pictorial_ids_list": pictorial_id_list} else:
return {"pictorial_ids_list": pictorial_id_list}
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) except:
return {"pictorial_ids_list": []} logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"pictorial_ids_list": []}
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