Commit a3694992 authored by 桂秋月's avatar 桂秋月

m

parent 262ed8bf
...@@ -38,13 +38,13 @@ mysql_info={ ...@@ -38,13 +38,13 @@ mysql_info={
"8066_27":{ "8066_27":{
"name":"real_data_test", "name":"real_data_test",
"pwd":"qpRBSarm$Tv*YO!n", "pwd":"qpRBSarm$Tv*YO!n",
"host":"172.30.5.27", "host":"off-line-db.quantgroups.com",
"port":"8066" "port":"8066"
}, },
"7438_27":{ "7438_27":{
"name":"xyqb_recommender_system_w", "name":"xyqb_recommender_system_w",
"pwd":"Qa6pxybKE8KgsUGV", "pwd":"Qa6pxybKE8KgsUGV",
"host":"172.30.5.27", "host":"off-line-db.quantgroups.com",
"port":"7438" "port":"7438"
}, },
"nearly":{ "nearly":{
...@@ -53,6 +53,13 @@ mysql_info={ ...@@ -53,6 +53,13 @@ mysql_info={
"host":"recommend-nearline-prod-5-7.cr22rydq7l0o.rds.cn-north-1.amazonaws.com.cn", "host":"recommend-nearline-prod-5-7.cr22rydq7l0o.rds.cn-north-1.amazonaws.com.cn",
"port":"3306" "port":"3306"
}, },
"89":{
"name":"root",
"pwd":"123456",
"host":"172.16.9.89",
"port":"3306"
}
,
"usergroup":{ "usergroup":{
"name":"tjzimuali_test", "name":"tjzimuali_test",
"pwd":"bYut032QgkJ7ElMXwW", "pwd":"bYut032QgkJ7ElMXwW",
......
...@@ -42,6 +42,7 @@ def execmysl(namespace,sql): ...@@ -42,6 +42,7 @@ def execmysl(namespace,sql):
if 'select' not in sql or 'from' not in sql: if 'select' not in sql or 'from' not in sql:
raise Exception('在mysql看来不是有效的sql',sql) raise Exception('在mysql看来不是有效的sql',sql)
try: try:
print(sql)
df=pd.read_sql(sql,con=mysql_universal(namespace)) df=pd.read_sql(sql,con=mysql_universal(namespace))
return df return df
except Exception as e: except Exception as e:
...@@ -72,5 +73,5 @@ def concatSql(sql,**kwargs): ...@@ -72,5 +73,5 @@ def concatSql(sql,**kwargs):
return sql+' where '+temp[:-4] return sql+' where '+temp[:-4]
if __name__ == '__main__': if __name__ == '__main__':
#print(mysqlInfo('test1')) print(mysqlInfo('test1'))
print(execmysl('qa',"select * from kdsp.t_brands limit 1")) #print(execmysl('test1',"select key_word as word,key_word_url as jumpUrl,icon_url as iconUrl from t_app_config_search_keyword where status=1 and DATE_FORMAT(end_time,'%Y-%m-%d') >= DATE_FORMAT('2022-06-14 15:38:50','%Y-%m-%d') and DATE_FORMAT('2022-06-14 15:38:50','%Y-%m-%d') >= DATE_FORMAT(start_time,'%Y-%m-%d') order by sort"))
\ No newline at end of file \ No newline at end of file
...@@ -9,3 +9,5 @@ from recommend.publicSql import * ...@@ -9,3 +9,5 @@ from recommend.publicSql import *
cur_dir=os.path.dirname(os.path.abspath(__file__)) cur_dir=os.path.dirname(os.path.abspath(__file__))
file_path=os.path.join(cur_dir,'tempFile') file_path=os.path.join(cur_dir,'tempFile')
nearline_url_aws="http://aws-online-recommend-parent.ec-test.qg-rc.net"
nearline_url_aliyun="http://172.16.9.90:19999"
\ No newline at end of file
import requests
from recommend import *
def preconditions(content,uuid,gid):
from search.abSearch import requestsend
try:
_, spu_nos,*_=requestsend(uuid,gid,content,selectedActivitie=1,page=1,searchtype='txt',env='test')
temp_spu_nos=spu_nos.split(',')
if len(temp_spu_nos)>5:
return 0
return temp_spu_nos
except:
return 0
def diwenci(uuid=None,gid=None):
url=nearline_url_aliyun+"/recommend/searchShadingWords"
body={
"position":1,
"userUuid":uuid or "",
"deviceId":gid or ""
}
temp=requests.get(url,params=body)
word=jsonpath.jsonpath(temp.json(),'$..word')
return word
def searchTopic(content):
#uuid,gid=genUuidDeviceid()
uuid=""
gid="4205df9318c69521"
print("uuid:",uuid,"====>","gid",gid)
#diwenci_result=diwenci(uuid,gid)
result_skus=preconditions(content,uuid,gid)
diwenci_result=diwenci(uuid,gid)
print("搜索结果的skus,",result_skus)
#query+similar_query
similar_temp=[]
similar_change_sql=recommend_hot_query_similar_info_sql+" where hot_query="+"'"+str(content)+"'" +" order by rank asc"
similar_df=execmysl('89',similar_change_sql)
similar_query_word=similar_df['hot_query_similar'].to_list() if not similar_df.empty else []
similar_temp+=similar_query_word
print("相似热词结果:",similar_temp)
##sku+query
if not result_skus:
print("底纹词,",diwenci_result)
##如果搜索没有商品数,则结果=相似搜索词+底纹词,并去重
return removeRepeat(similar_temp+diwenci_result[:3])
sku_match_change_sql=concatSql(recommend_sku_query_match_info_sql,**{"sku_no":result_skus}) +'order by rank asc'
sku_match_df=execmysl('89',sku_match_change_sql)
sku_match_change_df=sku_match_df.astype(str)[['sku_no','query']]. \
groupby(by='query')['sku_no'].count().reset_index(name='count') \
if not sku_match_df.empty else []
##通过query分组拿到skuno,如果3个元素的值都小于1,则空列表
try:
sku_match_temp=sku_match_change_df[sku_match_change_df['count']>1].sort_values(by='count',ascending=False)['query'].to_list()
except:
sku_match_temp=[]
finally:
if not (similar_temp and sku_match_temp):
return removeRepeat(diwenci_result)
print("商品相关词:",sku_match_temp)
##从sku的query结果中,去掉相似query,然后2边交叉排序
sku_match_temp_remove_from_similar=bingji(sku_match_temp,similar_temp)
##因为随机取不好弄,所以拿到所有数据交叉的
return listCross(similar_temp,sku_match_temp_remove_from_similar)
if __name__ == '__main__':
print(searchTopic('苹果耳机'))
...@@ -110,3 +110,14 @@ cate_brand_intention_score_sql=""" ...@@ -110,3 +110,14 @@ cate_brand_intention_score_sql="""
select * from select * from
offline_recommend.cate_brand_intention_score offline_recommend.cate_brand_intention_score
""" """
###query热词的相似表
recommend_hot_query_similar_info_sql="""
select * from online_recommend.recommend_hot_query_similar_info
"""
###商品和关键词的匹配度
recommend_sku_query_match_info_sql="""
select * from online_recommend.recommend_sku_query_match_info
"""
This diff is collapsed.
...@@ -254,7 +254,7 @@ if __name__ == '__main__': ...@@ -254,7 +254,7 @@ if __name__ == '__main__':
isexec=0 isexec=0
ishotwordrand=0 ishotwordrand=0
if isexec: if isexec:
allRun(1000,isFirstPage=1,sheetname=3,ishotwordrand=ishotwordrand) allRun(1,isFirstPage=1,sheetname=3,ishotwordrand=ishotwordrand)
else: else:
print(analysis()) print(analysis())
# a=[['236473224274432', '7188063'],['236473224274432', '7188063']] # a=[['236473224274432', '7188063'],['236473224274432', '7188063']]
......
...@@ -129,7 +129,7 @@ def requestsend(uuid,deviceid,searchContent,selectedActivitie,page=1,searchtype= ...@@ -129,7 +129,7 @@ def requestsend(uuid,deviceid,searchContent,selectedActivitie,page=1,searchtype=
total_skus=jsonpath.jsonpath(t.json(), '$..totalCount')[0] total_skus=jsonpath.jsonpath(t.json(), '$..totalCount')[0]
request_time = t.elapsed.total_seconds() request_time = t.elapsed.total_seconds()
#tttt=','.join(spu_nos) #tttt=','.join(spu_nos)
print(sku_nos) #print(sku_nos)
# with open('sku_result_3.txt', 'a+') as file: # with open('sku_result_3.txt', 'a+') as file:
# file.write('搜索词:' + searchContent + ";result:" + ','.join(sku_names) + "\n") # file.write('搜索词:' + searchContent + ";result:" + ','.join(sku_names) + "\n")
return page_size,sku_nos , str(request_time), search_id,','.join(sku_names),searchContent,total_skus return page_size,sku_nos , str(request_time), search_id,','.join(sku_names),searchContent,total_skus
...@@ -225,7 +225,7 @@ def totalrun(selectedActivitie=1, type='txt', num=0,isFirstPage=False,sheetname= ...@@ -225,7 +225,7 @@ def totalrun(selectedActivitie=1, type='txt', num=0,isFirstPage=False,sheetname=
temp.append(result_temp) temp.append(result_temp)
flag+=1 flag+=1
#filename=genReportName('searchResult') #filename=genReportName('searchResult')
print(temp) print('搜索接口响应处理后的结果:',temp)
return temp return temp
except: except:
traceback.print_exc(limit=2) traceback.print_exc(limit=2)
......
...@@ -28,4 +28,4 @@ def modifyPasseord(name,namespace): ...@@ -28,4 +28,4 @@ def modifyPasseord(name,namespace):
print("this is update") print("this is update")
if __name__ == '__main__': if __name__ == '__main__':
modifyPasseord('dong.chao','qa') modifyPasseord('haiyuan.wen','test1')
\ No newline at end of file \ No newline at end of file
...@@ -66,11 +66,35 @@ def listSubgroup(tt,size=6): ...@@ -66,11 +66,35 @@ def listSubgroup(tt,size=6):
return temp return temp
def countlist(a,num=0):
from collections import Counter
'''
:param a:
:param num:如果num不为空,则按num取前num个
:return: 重复元素计数
'''
temp=Counter(a)
if num:
return dict(temp.most_common(num))
return dict(temp.most_common(len(a)))
def bingji(a,b):
"""
:param a:
:param b:
:return: 并集
"""
temp=list(set(a).difference(set(b)))
temp.sort(key=a.index)
return temp
if __name__ == '__main__': if __name__ == '__main__':
a=[1,2,4,3,5,6,7,8] a=[2,2,4,3,5,6,7,8]
#print(listGroup(a)) b=[10,2,4,3,9]
print(bingji(b,a))
#a=[[1,2],[2,3]] #a=[[1,2],[2,3]]
#print(mergelist(a)) #print(mergelist(a))
print(listSubgroup(a,6)) #print(listSubgroup(a,6))
...@@ -5,7 +5,7 @@ def genUuidDeviceid(): ...@@ -5,7 +5,7 @@ def genUuidDeviceid():
:return: :return:
""" """
uuid,deviced=codeuuid.uuid4().urn.split(':')[-1],codeuuid.uuid4().urn.split(':')[-1] uuid,deviced=codeuuid.uuid4().urn.split(':')[-1],codeuuid.uuid4().urn.split(':')[-1]
uuid='87f491d2-527f-4386-9bb1-3d67017cb6d8' #uuid='87f491d2-527f-4386-9bb1-3d67017cb6d8'
deviced='guiqiuyue_'+str(deviced) deviced='guiqiuyue_'+str(deviced)
return uuid,deviced return uuid,deviced
......
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