Commit d3e160fa authored by 张彦钊's avatar 张彦钊

change

parent aac4ef4b
This diff is collapsed.
...@@ -56,8 +56,13 @@ def es_query(doc, body, offset, size, es=None): ...@@ -56,8 +56,13 @@ def es_query(doc, body, offset, size, es=None):
from_=offset, from_=offset,
size=size) size=size)
number = res["hits"]["total"] # number = res["hits"]["total"]
return number total = res["hits"]["hits"]
print(total)
r = []
for i in total:
r.append(i['_source']['id'])
return r
def answer(): def answer():
...@@ -884,11 +889,11 @@ def topic(): ...@@ -884,11 +889,11 @@ def topic():
"content_level": 3 "content_level": 3
} }
}, },
{ {
"term": { "term": {
"status": "3" "status": "3"
} }
}] }]
} }
} }
...@@ -917,11 +922,11 @@ def topic(): ...@@ -917,11 +922,11 @@ def topic():
"content_level": 4 "content_level": 4
} }
}, },
{ {
"term": { "term": {
"status": "3" "status": "3"
} }
}] }]
} }
} }
...@@ -950,11 +955,11 @@ def topic(): ...@@ -950,11 +955,11 @@ def topic():
"content_level": 5 "content_level": 5
} }
}, },
{ {
"term": { "term": {
"status": "3" "status": "3"
} }
}] }]
} }
} }
...@@ -983,11 +988,11 @@ def topic(): ...@@ -983,11 +988,11 @@ def topic():
"content_level": 3 "content_level": 3
} }
}, },
{ {
"term": { "term": {
"status": "3" "status": "3"
} }
}, {"term": {"is_video": True}}] }, {"term": {"is_video": True}}]
} }
} }
...@@ -1016,11 +1021,11 @@ def topic(): ...@@ -1016,11 +1021,11 @@ def topic():
"content_level": 4 "content_level": 4
} }
}, },
{ {
"term": { "term": {
"status": "3" "status": "3"
} }
}, {"term": {"is_video": True}}] }, {"term": {"is_video": True}}]
} }
} }
...@@ -1049,11 +1054,11 @@ def topic(): ...@@ -1049,11 +1054,11 @@ def topic():
"content_level": 5 "content_level": 5
} }
}, },
{ {
"term": { "term": {
"status": "3" "status": "3"
} }
}, {"term": {"is_video": True}}] }, {"term": {"is_video": True}}]
} }
} }
...@@ -1063,20 +1068,56 @@ def topic(): ...@@ -1063,20 +1068,56 @@ def topic():
tmp.append(es_query(category, video_star5_q, 0, 1)) tmp.append(es_query(category, video_star5_q, 0, 1))
total_list.append(tmp) total_list.append(tmp)
# print(i)
# print(tmp)
df = pd.DataFrame(total_list) df = pd.DataFrame(total_list)
df = df.rename(columns={0: "tag", 1: "star_3", 2: "star_4", 3: "star_5", df = df.rename(columns={0: "tag", 1: "star_3", 2: "star_4", 3: "star_5",
4: "video_star_3", 5: "video_star_4", 6: "video_star_5"}) 4: "video_star_3", 5: "video_star_4", 6: "video_star_5"})
df.to_csv("/home/gmuser/topic.csv", index=False, encoding="utf_8_sig") df.to_csv("/home/gmuser/topic.csv", index=False, encoding="utf_8_sig")
def test_topic():
query_operator = "and"
query_type = "cross_fields"
category = 'tractate'
query = "眶隔脂肪释放术"
star3_q = {
"query": {"filtered": {
"filter": {
"bool": {
"must": [{
"multi_match": {
"fields": ["content^1", "author^1", "tractate_tag_name^1",
"tractate_tag_name_content^1"],
"operator": query_operator,
"type": query_type,
"query": query
}
}, {
"term": {
"is_online": True
}
}, {"term": {
"content_level": 3
}
},
{
"term": {
"status": "3"
}
}]
}
}
}
},"_source":{"include":"id"}
}
print(es_query(category, star3_q, 0, 10))
if __name__ == "__main__": if __name__ == "__main__":
answer() test_topic()
topic()
print("topic")
question()
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