Commit ace65e2a authored by litaolemo's avatar litaolemo

update

parent 069679c8
...@@ -16,8 +16,6 @@ es = Elasticsearch([ ...@@ -16,8 +16,6 @@ es = Elasticsearch([
def get_device_num_from_es(word): def get_device_num_from_es(word):
if word in exists_es_dic:
return exists_es_dic[word]
results = es.search( results = es.search(
index='gm-dbmw-device', index='gm-dbmw-device',
...@@ -162,13 +160,13 @@ def get_device_num_from_es(word): ...@@ -162,13 +160,13 @@ def get_device_num_from_es(word):
} }
) )
tractate_content_num = results["hits"]["total"] tractate_content_num = results["hits"]["total"]
exists_es_dic[word] = tractate_content_num
return tractate_content_num return tractate_content_num
def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", "first_solutions", "second_solutions", def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", "first_solutions", "second_solutions",
"positions", "second_positions", "tags_v3"]): "positions", "second_positions", "tags_v3"]):
# {tag_name:(answer_content_num, tractate_content_num, diary_content_num, total_num)} # {tag_name:(answer_content_num, tractate_content_num, diary_content_num, total_num)}
article_dict = { article_dict = {
"first_demands": [], "first_demands": [],
"second_demands": [], "second_demands": [],
...@@ -184,6 +182,9 @@ def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", " ...@@ -184,6 +182,9 @@ def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", "
for tag_type in tag_dict: for tag_type in tag_dict:
for tag_name in tag_dict[tag_type]: for tag_name in tag_dict[tag_type]:
if tag_name in exists_es_dic:
article_dict[tag_type].append(exists_es_dic[tag_name])
continue
body = { body = {
"query": { "query": {
"bool": { "bool": {
...@@ -286,6 +287,7 @@ def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", " ...@@ -286,6 +287,7 @@ def get_es_article_num(tag_dict, allow_tag=["first_demands", "second_demands", "
total_num = answer_content_num + tractate_content_num + diary_content_num total_num = answer_content_num + tractate_content_num + diary_content_num
data_dic = {tag_name: (answer_content_num, tractate_content_num, diary_content_num, total_num)} data_dic = {tag_name: (answer_content_num, tractate_content_num, diary_content_num, total_num)}
# print(data_dic) # print(data_dic)
exists_es_dic[tag_name] = data_dic
article_dict[tag_type].append(data_dic) article_dict[tag_type].append(data_dic)
return article_dict return article_dict
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