|
@@ -48,20 +48,20 @@ class SearchABTest(object):
|
|
"""
|
|
"""
|
|
兜底策略
|
|
兜底策略
|
|
"""
|
|
"""
|
|
- result = await SearchMethod().search_v0(
|
|
|
|
|
|
+ result = await SearchMethod().search_v1(
|
|
text=cls.article_keys[0],
|
|
text=cls.article_keys[0],
|
|
trace_id=cls.trace_id
|
|
trace_id=cls.trace_id
|
|
)
|
|
)
|
|
if result:
|
|
if result:
|
|
return result
|
|
return result
|
|
else:
|
|
else:
|
|
- sub_result = await SearchMethod().search_v0(
|
|
|
|
|
|
+ sub_result = await SearchMethod().search_v1(
|
|
text=cls.article_keys[1],
|
|
text=cls.article_keys[1],
|
|
trace_id=cls.trace_id)
|
|
trace_id=cls.trace_id)
|
|
if sub_result:
|
|
if sub_result:
|
|
return sub_result
|
|
return sub_result
|
|
else:
|
|
else:
|
|
- return await SearchMethod().search_v0(
|
|
|
|
|
|
+ return await SearchMethod().search_v1(
|
|
text=cls.article_keys[2],
|
|
text=cls.article_keys[2],
|
|
trace_id=cls.trace_id
|
|
trace_id=cls.trace_id
|
|
)
|
|
)
|
|
@@ -72,7 +72,7 @@ class SearchABTest(object):
|
|
默认原标题搜索
|
|
默认原标题搜索
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- search_result = await SearchMethod().search_v0(
|
|
|
|
|
|
+ search_result = await SearchMethod().search_v1(
|
|
text=cls.ori_title,
|
|
text=cls.ori_title,
|
|
trace_id=cls.trace_id
|
|
trace_id=cls.trace_id
|
|
)
|
|
)
|
|
@@ -87,7 +87,7 @@ class SearchABTest(object):
|
|
使用 content_summary搜索
|
|
使用 content_summary搜索
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- search_result = await SearchMethod().search_v0(
|
|
|
|
|
|
+ search_result = await SearchMethod().search_v1(
|
|
text=cls.article_summary,
|
|
text=cls.article_summary,
|
|
trace_id=cls.trace_id
|
|
trace_id=cls.trace_id
|
|
)
|
|
)
|
|
@@ -102,7 +102,7 @@ class SearchABTest(object):
|
|
使用文本关键词搜索
|
|
使用文本关键词搜索
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- search_result = await SearchMethod().search_v0(
|
|
|
|
|
|
+ search_result = await SearchMethod().search_v1(
|
|
text=cls.article_keys[0],
|
|
text=cls.article_keys[0],
|
|
trace_id=cls.trace_id
|
|
trace_id=cls.trace_id
|
|
)
|
|
)
|
|
@@ -117,7 +117,7 @@ class SearchABTest(object):
|
|
使用文本关键词搜索
|
|
使用文本关键词搜索
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- search_result = await SearchMethod().search_v0(
|
|
|
|
|
|
+ search_result = await SearchMethod().search_v1(
|
|
text=cls.article_keys[1],
|
|
text=cls.article_keys[1],
|
|
trace_id=cls.trace_id
|
|
trace_id=cls.trace_id
|
|
)
|
|
)
|
|
@@ -132,7 +132,7 @@ class SearchABTest(object):
|
|
使用文本关键词搜索
|
|
使用文本关键词搜索
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- search_result = await SearchMethod().search_v0(
|
|
|
|
|
|
+ search_result = await SearchMethod().search_v1(
|
|
text=cls.article_keys[2],
|
|
text=cls.article_keys[2],
|
|
trace_id=cls.trace_id
|
|
trace_id=cls.trace_id
|
|
)
|
|
)
|
|
@@ -188,6 +188,46 @@ class SearchMethod(object):
|
|
)
|
|
)
|
|
return None
|
|
return None
|
|
|
|
|
|
|
|
+ @classmethod
|
|
|
|
+ async def search_v1(cls, text, trace_id):
|
|
|
|
+ """
|
|
|
|
+ dy ---> baidu ---> xigua
|
|
|
|
+ :param text:
|
|
|
|
+ :param trace_id:
|
|
|
|
+ :return:
|
|
|
|
+ """
|
|
|
|
+ douyin_result = douyin_search(keyword=text, sensitive_words=cls.s_words)
|
|
|
|
+ if douyin_result:
|
|
|
|
+ return {"platform": "dy_search", "result": douyin_result[0]}
|
|
|
|
+ else:
|
|
|
|
+ logging(
|
|
|
|
+ code="7001",
|
|
|
|
+ info="抖音搜索失败--{}".format(text),
|
|
|
|
+ trace_id=trace_id
|
|
|
|
+ )
|
|
|
|
+ time.sleep(1)
|
|
|
|
+ baidu_result = hksp_search(key=text, sensitive_words=cls.s_words)
|
|
|
|
+ if baidu_result:
|
|
|
|
+ return {"platform": "baidu_search", "result": baidu_result[0]}
|
|
|
|
+ else:
|
|
|
|
+ # 若好看视频未搜到,则采用西瓜搜索
|
|
|
|
+ logging(
|
|
|
|
+ code="7001",
|
|
|
|
+ info="通过baidu搜索失败---{}".format(text),
|
|
|
|
+ trace_id=trace_id,
|
|
|
|
+ )
|
|
|
|
+ # return None
|
|
|
|
+ xigua_result = xigua_search_v2(keyword=text, sensitive_words=cls.s_words)
|
|
|
|
+ if xigua_result:
|
|
|
|
+ return {"platform": "xg_search", "result": xigua_result[0]}
|
|
|
|
+ else:
|
|
|
|
+ logging(
|
|
|
|
+ code="7001",
|
|
|
|
+ info="通过西瓜搜索失败---{}, 启用兜底方式".format(text),
|
|
|
|
+ trace_id=trace_id,
|
|
|
|
+ )
|
|
|
|
+ return None
|
|
|
|
+
|
|
|
|
|
|
async def video_sender(video_obj, user, trace_id, platform):
|
|
async def video_sender(video_obj, user, trace_id, platform):
|
|
"""
|
|
"""
|
|
@@ -219,6 +259,12 @@ async def video_sender(video_obj, user, trace_id, platform):
|
|
user=user,
|
|
user=user,
|
|
trace_id=trace_id,
|
|
trace_id=trace_id,
|
|
)
|
|
)
|
|
|
|
+ elif platform == "dy_search":
|
|
|
|
+ mq_obj = Video.dy_video_producer(
|
|
|
|
+ video_obj=video_obj,
|
|
|
|
+ user=user,
|
|
|
|
+ trace_id=trace_id,
|
|
|
|
+ )
|
|
else:
|
|
else:
|
|
mq_obj = {}
|
|
mq_obj = {}
|
|
AE = AsyncETL(video_obj=mq_obj)
|
|
AE = AsyncETL(video_obj=mq_obj)
|
|
@@ -243,7 +289,7 @@ async def search_videos(params, trace_id, gh_id, mysql_client):
|
|
"""
|
|
"""
|
|
K = KimiServer()
|
|
K = KimiServer()
|
|
kimi_info = await K.search_kimi_schedule(params=params)
|
|
kimi_info = await K.search_kimi_schedule(params=params)
|
|
- print(json.dumps(kimi_info, ensure_ascii=False, indent=4))
|
|
|
|
|
|
+ print("{}---kimi 挖掘正常".format(trace_id))
|
|
kimi_title = kimi_info['k_title']
|
|
kimi_title = kimi_info['k_title']
|
|
content_title = kimi_info['content_title'].replace("'", "").replace('"', "")
|
|
content_title = kimi_info['content_title'].replace("'", "").replace('"', "")
|
|
content_keys = json.dumps(kimi_info['content_keys'], ensure_ascii=False)
|
|
content_keys = json.dumps(kimi_info['content_keys'], ensure_ascii=False)
|
|
@@ -258,10 +304,12 @@ async def search_videos(params, trace_id, gh_id, mysql_client):
|
|
kimi_info["trace_id"] = trace_id
|
|
kimi_info["trace_id"] = trace_id
|
|
SearchAB = SearchABTest(info=kimi_info, gh_id=gh_id)
|
|
SearchAB = SearchABTest(info=kimi_info, gh_id=gh_id)
|
|
recall_obj_1 = await SearchAB.ab_1()
|
|
recall_obj_1 = await SearchAB.ab_1()
|
|
|
|
+ # recall_obj_1 = await SearchAB.ab_0()
|
|
await asyncio.sleep(3)
|
|
await asyncio.sleep(3)
|
|
recall_obj_2 = await SearchAB.ab_2()
|
|
recall_obj_2 = await SearchAB.ab_2()
|
|
await asyncio.sleep(3)
|
|
await asyncio.sleep(3)
|
|
recall_obj_3 = await SearchAB.ab_3()
|
|
recall_obj_3 = await SearchAB.ab_3()
|
|
|
|
+ print("{}---视频搜索正常".format(trace_id))
|
|
recall_list = [recall_obj_1, recall_obj_2, recall_obj_3]
|
|
recall_list = [recall_obj_1, recall_obj_2, recall_obj_3]
|
|
un_empty_list = [i for i in recall_list if i]
|
|
un_empty_list = [i for i in recall_list if i]
|
|
if len(un_empty_list) < 3:
|
|
if len(un_empty_list) < 3:
|
|
@@ -302,5 +350,3 @@ async def search_videos(params, trace_id, gh_id, mysql_client):
|
|
info="视频搜索失败, 被敏感词过滤",
|
|
info="视频搜索失败, 被敏感词过滤",
|
|
trace_id=trace_id
|
|
trace_id=trace_id
|
|
)
|
|
)
|
|
-
|
|
|
|
-
|
|
|