Commit 44aabeea authored by 段英荣's avatar 段英荣

Merge branch 'similar_sort' into 'master'

Similar sort

See merge request alpha/physical!156
parents 01f3273d ae9414e2
......@@ -59,7 +59,7 @@ class LinUCB:
AaI_tmp = np.array(Aa_list)
theta_tmp = np.array(theta_list)
top_tag_list_len = len(tag_list)/3
top_tag_list_len = int(len(tag_list)/3)
top_np_ind = np.argpartition(np.dot(xaT, theta_tmp) + cls.alpha * np.sqrt(np.dot(np.dot(xaT, AaI_tmp), xa)), -top_tag_list_len)[-top_tag_list_len:]
top_tag_list = list()
......
......@@ -240,24 +240,24 @@ class TopicUtils(object):
{"term": {"has_image":True}},
{"term": {"is_online": True}},
{"term": {"is_deleted": False}}
],
"should": [
{
"bool":{
"must":[
{"term":{"has_image":True}},
{"term": {"has_video": False}}
]
# "should": [
# {
# "bool":{
# "must":[
# {"term":{"has_image":True}},
# {"term": {"has_video": False}}
# ]
# }
# },{
# "bool":{
# "must":{
# "term":{"has_video":True}
# }
# }
# }
# ],
# "minimum_should_match":1
}
},{
"bool":{
"must":{
"term":{"has_video":True}
}
}
}
],
"minimum_should_match":1
}
},
"score_mode": "sum",
......
......@@ -171,18 +171,35 @@ class TypeInfo(object):
)
def insert_table_by_pk_list(self, sub_index_name, pk_list, es=None, use_batch_query_set=False):
begin = time.time()
if use_batch_query_set:
qs = self.queryset
else:
qs = self.model.objects.all()
end = time.time()
time0=end-begin
begin = time.time()
instance_list = qs.filter(pk__in=pk_list)
end = time.time()
time1=end-begin
begin = time.time()
data_list = self.bulk_get_data(instance_list)
end = time.time()
time2=end-begin
begin = time.time()
self.elasticsearch_bulk_insert_data(
sub_index_name=sub_index_name,
data_list=data_list,
es=es,
)
end = time.time()
time3=end-begin
logging.info("duan add,insert_table_by_pk_list time cost:%ds,%ds,%ds,%ds" % (time0,time1,time2,time3))
def insert_table_chunk(self, sub_index_name, table_chunk, es=None):
try:
......
......@@ -34,31 +34,36 @@ class TopicTransfer(object):
res["group_id"] = -1
res["share_num"] = instance.share_num
begin = time.time()
res["pick_id_list"] = instance.get_pick_id_info()
end = time.time()
time0 = (end-begin)
begin = datetime.datetime.now()
begin = time.time()
(topic_tag_id_list, edit_tag_id_list) = instance.get_topic_tag_id_list()
res["tag_list"] = topic_tag_id_list
res["edit_tag_list"] = edit_tag_id_list
end = datetime.datetime.now()
time1 = (end-begin).seconds
end = time.time()
time1 = (end-begin)
begin = datetime.datetime.now()
begin = time.time()
res["tag_name_list"] = instance.get_tag_name_list(res["tag_list"])
end = datetime.datetime.now()
time2 = (end-begin).seconds
end = time.time()
time2 = (end-begin)
begin = datetime.datetime.now()
begin = time.time()
res["offline_score"] = instance.get_topic_offline_score()
end = datetime.datetime.now()
time3 = (end-begin).seconds
end = time.time()
time3 = (end-begin)
begin = time.time()
res["manual_score"] = instance.drop_score
res["has_image"] = instance.topic_has_image()
res["has_video"] = instance.has_video
res["language_type"] = instance.language_type
end = time.time()
time4 = (end-begin)
# # 片假名
# re_jp_pian_words = re.compile(u"[\u30a0-\u30ff]+")
......@@ -85,7 +90,7 @@ class TopicTransfer(object):
res["update_time"] = tzlc_update_time
res["update_time_val"] = int(time.mktime(tzlc_update_time.timetuple()))
logging.info("test topic transfer time cost,time1:%d,time2:%d,time3:%d" % (time1,time2,time3))
logging.info("test topic transfer time cost,time0:%d,time1:%d,time2:%d,time3:%d,time4:%d" % (time0,time1,time2,time3,time4))
return res
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......
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