Commit 3899ebbf authored by 赵威's avatar 赵威

add new tag3 cold start

parent 71e42e09
import json
import redis
from es_tool import es_query
keywords = [
"瘦脸", "双眼皮", "补水", "美白嫩肤", "瘦小腿", "除皱", "隆鼻", "牙齿矫正", "脱毛", "祛斑", "控油", "面部祛脂", "隆胸", "垫鼻基底", "缩鼻翼", "生头发", "开眼角", "瘦肩", "祛痘",
"缩毛孔", "轮廓改善", "除眼底细纹", "眼部修复", "垫下巴", "颧骨内推", "除法令纹", "缩咬肌", "瘦臀部", "丰眼窝", "瘦手臂", "丰唇", "瘦腰腹", "瘦大腿", "填充泪沟", "洁面", "除面部细纹",
"上眼睑提升", "大眼睛", "缩短眼距离", "除印第安纹", "瘦全身", "下巴改善", "祛双下巴", "祛痘印", "眼部护理", "缩窄下巴", "缩短下巴", "填充苹果肌", "祛痘坑", "填充卧蚕"
]
def get_es_diary(keywords, city_tag_id=-1, version=False):
q = {}
sort_list = [{
"_script": {
"lang": "groovy",
"script_file": "sort_diary-recommend",
"type": "number",
"params": {
"user_city_tag_id": city_tag_id,
},
"order": "desc",
"_cache": True,
}
}]
if version:
sort_list += [{
"has_video_cover": {
"order": "asc"
}
}, {
"offline_score_v1": {
"order": "desc"
}
}, {
"good_click": {
"order": "desc"
}
}, {
"last_update_time": {
"order": "desc"
}
}]
else:
sort_list += [{
"has_video_cover": {
"order": "asc"
}
}, {
"offline_score": {
"order": "desc"
}
}, {
"good_click": {
"order": "desc"
}
}, {
"last_update_time": {
"order": "desc"
}
}]
should_list = [{
"terms": {
"first_demands": keywords
}
}, {
"terms": {
"second_demands": keywords
}
}, {
"terms": {
"first_solutions": keywords
}
}, {
"terms": {
"second_solutions": keywords
}
}, {
"terms": {
"positions": keywords
}
}, {
"terms": {
"second_positions": keywords
}
}, {
"terms": {
"tags_v3": keywords
}
}]
q["query"] = {
"bool": {
"filter": [{
"term": {
"is_online": True
}
}, {
"term": {
"has_cover": True
}
}, {
"term": {
"is_sink": False
}
}, {
"term": {
"has_after_cover": True
}
}, {
"term": {
"has_before_cover": True
}
}, {
"terms": {
"content_level": [6, 5, 4, 3.5, 3]
}
}],
"should":
should_list,
"minimum_should_match":
1
}
}
q["sort"] = sort_list
q["_source"] = {"includes": ["id", "second_demands"]}
es_res = es_query("diary", q, offset=0, size=500)
diary_ids = []
for diary_info in es_res["hits"]["hits"]:
diary_ids.append(diary_info["_source"]["id"])
return diary_ids
if __name__ == "__main__":
ids = get_es_diary(keywords)
print(ids)
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