Commit 0d7ef5e2 authored by lixiaofang's avatar lixiaofang

Merge branch 'hotword' into test

parents a19efb8b 8c600a7b
...@@ -279,7 +279,7 @@ def search_physical(query="", offset=0, size=10): ...@@ -279,7 +279,7 @@ def search_physical(query="", offset=0, size=10):
result_dicts = GroupUtils.get_search_pictorial_topic(query, offset, size) result_dicts = GroupUtils.get_search_pictorial_topic(query, offset, size)
group_ids_list = [] group_ids_list = []
if len(result_dicts["hits"]) > 0: if len(result_dicts["hits"]) > 0:
group_ids_list = [item["_source"]["id"] for item in result_dict["hits"]] group_ids_list = [item["_source"]["id"] for item in result_dicts["hits"]]
return {"search_topic_ids": group_ids_list} return {"search_topic_ids": group_ids_list}
except: except:
......
...@@ -33,9 +33,29 @@ def search_hotword(device_id=-1): ...@@ -33,9 +33,29 @@ def search_hotword(device_id=-1):
try: try:
all_tag_name_list = set() all_tag_name_list = set()
# 获取搜索推荐热词 # 获取搜索推荐热词
results_registr_tag = RegisterShowTag.objects.filter(is_deleted=False, is_online=1).count() results_registr_tag = RegisterShowTag.objects.filter(is_deleted=False, is_online=1).count()
results_tag = Tag.objects.filter(is_online=True, collection=1).count()
# 获取符合条件的核心词
q = {}
q["query"] = {
"bool": {
"must": [
{"term": {
"is_online": True
}},
{"term": {
"collection": 1
}
}
]
}
}
es_cli_obj = ESPerform.get_cli()
result_dict = ESPerform.get_search_results(es_cli_obj, "tag", q, offset, size)
results_tag = result_dict["hits"]["total"]
logging.info("get totoal:%s" % results_tag)
# results_tag = Tag.objects.filter(is_online=True, collection=1).count()
tag_id = random.sample(range(1, results_registr_tag), 1) tag_id = random.sample(range(1, results_registr_tag), 1)
results_tag_chose = Tag.objects.filter(id__in=tag_id).values_list("name", flat=True) results_tag_chose = Tag.objects.filter(id__in=tag_id).values_list("name", flat=True)
for i in results_tag_chose: for i in results_tag_chose:
......
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