Commit ac249a6f authored by 段英荣's avatar 段英荣

Merge branch 'hk_now' into 'test'

add mapping

See merge request alpha/physical!336
parents 9d3a5615 da90b7f7
...@@ -24,29 +24,5 @@ ...@@ -24,29 +24,5 @@
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" /> <option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings> </formatting-settings>
</DBN-SQL> </DBN-SQL>
<DBN-PSQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
</code_scheme> </code_scheme>
</component> </component>
\ No newline at end of file
...@@ -35,7 +35,7 @@ class TopicUtils(object): ...@@ -35,7 +35,7 @@ class TopicUtils(object):
} }
q["_source"] = { q["_source"] = {
"include": ["tag_list", "attention_user_id_list", "pick_user_id_list", "same_pictorial_user_id_list"] "include": ["tag_list","attention_user_id_list", "pick_user_id_list", "same_pictorial_user_id_list"]
} }
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), "user", q, offset, size) result_dict = ESPerform.get_search_results(ESPerform.get_cli(), "user", q, offset, size)
...@@ -141,14 +141,12 @@ class TopicUtils(object): ...@@ -141,14 +141,12 @@ class TopicUtils(object):
# pick_user_id_list = list() # pick_user_id_list = list()
# same_group_id_list = list() # same_group_id_list = list()
user_tag_list = list() user_tag_list = list()
result_dict = TopicUtils.get_related_user_info(user_id, 0, 1) result_dict = TopicUtils.get_related_user_info(user_id, 0, 1)
if len(result_dict["hits"]) == 0: if len(result_dict["hits"]) == 0:
logging.warning("not find user_id:%d in es!" % int(user_id)) logging.warning("not find user_id:%d in es!" % int(user_id))
else: else:
attention_user_info_list = result_dict["hits"][0]["_source"]["attention_user_id_list"] attention_user_info_list = result_dict["hits"][0]["_source"]["attention_user_id_list"]
attention_user_id_list = [item["user_id"] for item in attention_user_info_list] attention_user_id_list = [item["user_id"] for item in attention_user_info_list]
# pick_user_info_list = result_dict["hits"][0]["_source"]["pick_user_id_list"] # pick_user_info_list = result_dict["hits"][0]["_source"]["pick_user_id_list"]
# pick_user_id_list = [item["user_id"] for item in pick_user_info_list] # pick_user_id_list = [item["user_id"] for item in pick_user_info_list]
...@@ -197,7 +195,6 @@ class TopicUtils(object): ...@@ -197,7 +195,6 @@ class TopicUtils(object):
"weight": 100 "weight": 100
} }
) )
query_function_score = { query_function_score = {
"query": { "query": {
"bool": { "bool": {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"user_nick_name_pre": {"type":"text","analyzer":"keyword"}, //不切词的用户名 "user_nick_name_pre": {"type":"text","analyzer":"keyword"}, //不切词的用户名
"group_id":{"type":"long"}, //所在组ID "group_id":{"type":"long"}, //所在组ID
"tag_list":{"type":"long"},//标签属性 "tag_list":{"type":"long"},//标签属性
"useful_tag_list":{"type":"long"},//有用标签属性
"edit_tag_list":{"type":"long"},//编辑标签 "edit_tag_list":{"type":"long"},//编辑标签
"tag_name_list":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"}, "tag_name_list":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"share_num":{"type":"long"}, "share_num":{"type":"long"},
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"user_nick_name":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},//帖子用户名 "user_nick_name":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},//帖子用户名
"user_nick_name_pre": {"type":"text","analyzer":"keyword"}, //不切词的用户名 "user_nick_name_pre": {"type":"text","analyzer":"keyword"}, //不切词的用户名
"group_id":{"type":"long"}, //所在组ID "group_id":{"type":"long"}, //所在组ID
"useful_tag_list":{"type":"long"},//有用标签属性
"tag_list":{"type":"long"},//标签属性 "tag_list":{"type":"long"},//标签属性
"edit_tag_list":{"type":"long"},//编辑标签 "edit_tag_list":{"type":"long"},//编辑标签
"tag_name_list":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"}, "tag_name_list":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"user_nick_name_pre": {"type":"text","analyzer":"keyword"}, //不切词的用户名 "user_nick_name_pre": {"type":"text","analyzer":"keyword"}, //不切词的用户名
"group_id":{"type":"long"}, //所在组ID "group_id":{"type":"long"}, //所在组ID
"tag_list":{"type":"long"},//标签属性 "tag_list":{"type":"long"},//标签属性
"useful_tag_list":{"type":"long"},//有用标签属性
"edit_tag_list":{"type":"long"},//编辑标签 "edit_tag_list":{"type":"long"},//编辑标签
"tag_name_list":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"}, "tag_name_list":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"share_num":{"type":"long"}, "share_num":{"type":"long"},
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"is_online":{"type":"boolean"},//是否上线 "is_online":{"type":"boolean"},//是否上线
"is_deleted":{"type":"boolean"}, "is_deleted":{"type":"boolean"},
"tag_list":{"type":"long"},//标签属性 "tag_list":{"type":"long"},//标签属性
"useful_tag_list":{"type":"long"},//有用标签属性
"city_id":{"type":"text"}, "city_id":{"type":"text"},
"country_id":{"type":"text"}, "country_id":{"type":"text"},
"is_recommend":{"type":"boolean"},//是否运营推荐用户 "is_recommend":{"type":"boolean"},//是否运营推荐用户
......
...@@ -20,6 +20,7 @@ class TopicTag(models.Model): ...@@ -20,6 +20,7 @@ class TopicTag(models.Model):
topic_id = models.IntegerField(verbose_name=u"帖子ID") topic_id = models.IntegerField(verbose_name=u"帖子ID")
is_online = models.BooleanField(verbose_name=u"是否在线") is_online = models.BooleanField(verbose_name=u"是否在线")
is_collection = models.IntegerField(verbose_name=u"是否编辑标签") is_collection = models.IntegerField(verbose_name=u"是否编辑标签")
is_body_esthetics = models.IntegerField(verbose_name=u"是否有用标签")
class AccountUserTag(models.Model): class AccountUserTag(models.Model):
...@@ -33,6 +34,7 @@ class AccountUserTag(models.Model): ...@@ -33,6 +34,7 @@ class AccountUserTag(models.Model):
is_deleted = models.BooleanField(verbose_name=u"是否删除") is_deleted = models.BooleanField(verbose_name=u"是否删除")
create_time = models.DateTimeField(verbose_name=u'创建时间',default=datetime.datetime.fromtimestamp(0)) create_time = models.DateTimeField(verbose_name=u'创建时间',default=datetime.datetime.fromtimestamp(0))
update_time = models.DateTimeField(verbose_name=u'更新时间', default=datetime.datetime.fromtimestamp(0)) update_time = models.DateTimeField(verbose_name=u'更新时间', default=datetime.datetime.fromtimestamp(0))
is_body_esthetics = models.IntegerField(verbose_name=u"是否有用标签")
class Tag(models.Model): class Tag(models.Model):
......
...@@ -191,6 +191,18 @@ class Topic(models.Model): ...@@ -191,6 +191,18 @@ class Topic(models.Model):
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return ([],[]) return ([],[])
def get_topic_useful_tag_id_list(self):
try:
topic_useful_tag_id_list = list()
tag_id_list = TopicTag.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id,is_online =True,is_body_esthetics = 1)
for tag_item in tag_id_list:
topic_useful_tag_id_list.append(tag_item.tag_id)
return topic_useful_tag_id_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
def get_tag_name_list(self, tag_id_list): def get_tag_name_list(self, tag_id_list):
try: try:
tag_name_list = list() tag_name_list = list()
......
...@@ -189,3 +189,16 @@ class User(models.Model): ...@@ -189,3 +189,16 @@ class User(models.Model):
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return [] return []
def get_user_useful_tag_id_list(self):
try:
user_useful_tag_id_list = list()
query_results = AccountUserTag.objects.using(settings.SLAVE_DB_NAME).filter(user=self.user_id,is_body_esthetics =1, is_deleted=False)
for item in query_results:
user_useful_tag_id_list.append(item.tag_id)
return user_useful_tag_id_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
\ No newline at end of file
...@@ -75,6 +75,11 @@ class TopicTransfer(object): ...@@ -75,6 +75,11 @@ class TopicTransfer(object):
end = time.time() end = time.time()
time4 = (end-begin) time4 = (end-begin)
# begin = time.time()
topic_useful_tag_id_list= instance.get_topic_useful_tag_id_list()
res["useful_tag_list"] = topic_useful_tag_id_list
# end = time.time()
# time5 = (end - begin)
# # 片假名 # # 片假名
# re_jp_pian_words = re.compile(u"[\u30a0-\u30ff]+") # re_jp_pian_words = re.compile(u"[\u30a0-\u30ff]+")
# m_pian = re_jp_pian_words.search(instance.content, 0) # m_pian = re_jp_pian_words.search(instance.content, 0)
......
...@@ -73,6 +73,7 @@ class UserTransfer(object): ...@@ -73,6 +73,7 @@ class UserTransfer(object):
try: try:
res["tag_list"] = instance.get_user_tag_id_list() res["tag_list"] = instance.get_user_tag_id_list()
res["useful_tag_list"] = instance.get_user_useful_tag_id_list()
res["attention_user_id_list"] = cls.get_follow_user_id_list(userInstance=instance) res["attention_user_id_list"] = cls.get_follow_user_id_list(userInstance=instance)
# res["attention_group_id_list"] = instance.get_attention_group_id_list() # res["attention_group_id_list"] = instance.get_attention_group_id_list()
......
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