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: ...@@ -59,7 +59,7 @@ class LinUCB:
AaI_tmp = np.array(Aa_list) AaI_tmp = np.array(Aa_list)
theta_tmp = np.array(theta_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_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() top_tag_list = list()
......
...@@ -240,24 +240,24 @@ class TopicUtils(object): ...@@ -240,24 +240,24 @@ class TopicUtils(object):
{"term": {"has_image":True}}, {"term": {"has_image":True}},
{"term": {"is_online": True}}, {"term": {"is_online": True}},
{"term": {"is_deleted": False}} {"term": {"is_deleted": False}}
] ],
# "should": [ "should": [
# { {
# "bool":{ "bool":{
# "must":[ "must":[
# {"term":{"has_image":True}}, {"term":{"has_image":True}},
# {"term": {"has_video": False}} {"term": {"has_video": False}}
# ] ]
# } }
# },{ },{
# "bool":{ "bool":{
# "must":{ "must":{
# "term":{"has_video":True} "term":{"has_video":True}
# } }
# } }
# } }
# ], ],
# "minimum_should_match":1 "minimum_should_match":1
} }
}, },
"score_mode": "sum", "score_mode": "sum",
......
...@@ -171,18 +171,35 @@ class TypeInfo(object): ...@@ -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): 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: if use_batch_query_set:
qs = self.queryset qs = self.queryset
else: else:
qs = self.model.objects.all() qs = self.model.objects.all()
end = time.time()
time0=end-begin
begin = time.time()
instance_list = qs.filter(pk__in=pk_list) 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) data_list = self.bulk_get_data(instance_list)
end = time.time()
time2=end-begin
begin = time.time()
self.elasticsearch_bulk_insert_data( self.elasticsearch_bulk_insert_data(
sub_index_name=sub_index_name, sub_index_name=sub_index_name,
data_list=data_list, data_list=data_list,
es=es, 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): def insert_table_chunk(self, sub_index_name, table_chunk, es=None):
try: try:
......
...@@ -34,31 +34,36 @@ class TopicTransfer(object): ...@@ -34,31 +34,36 @@ class TopicTransfer(object):
res["group_id"] = -1 res["group_id"] = -1
res["share_num"] = instance.share_num res["share_num"] = instance.share_num
begin = time.time()
res["pick_id_list"] = instance.get_pick_id_info() 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() (topic_tag_id_list, edit_tag_id_list) = instance.get_topic_tag_id_list()
res["tag_list"] = topic_tag_id_list res["tag_list"] = topic_tag_id_list
res["edit_tag_list"] = edit_tag_id_list res["edit_tag_list"] = edit_tag_id_list
end = datetime.datetime.now() end = time.time()
time1 = (end-begin).seconds time1 = (end-begin)
begin = datetime.datetime.now() begin = time.time()
res["tag_name_list"] = instance.get_tag_name_list(res["tag_list"]) res["tag_name_list"] = instance.get_tag_name_list(res["tag_list"])
end = datetime.datetime.now() end = time.time()
time2 = (end-begin).seconds time2 = (end-begin)
begin = datetime.datetime.now() begin = time.time()
res["offline_score"] = instance.get_topic_offline_score() res["offline_score"] = instance.get_topic_offline_score()
end = datetime.datetime.now() end = time.time()
time3 = (end-begin).seconds time3 = (end-begin)
begin = time.time()
res["manual_score"] = instance.drop_score res["manual_score"] = instance.drop_score
res["has_image"] = instance.topic_has_image() res["has_image"] = instance.topic_has_image()
res["has_video"] = instance.has_video res["has_video"] = instance.has_video
res["language_type"] = instance.language_type res["language_type"] = instance.language_type
end = time.time()
time4 = (end-begin)
# # 片假名 # # 片假名
# re_jp_pian_words = re.compile(u"[\u30a0-\u30ff]+") # re_jp_pian_words = re.compile(u"[\u30a0-\u30ff]+")
...@@ -85,7 +90,7 @@ class TopicTransfer(object): ...@@ -85,7 +90,7 @@ class TopicTransfer(object):
res["update_time"] = tzlc_update_time res["update_time"] = tzlc_update_time
res["update_time_val"] = int(time.mktime(tzlc_update_time.timetuple())) 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 return res
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) 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