Commit 60abc391 authored by 段英荣's avatar 段英荣

Merge branch 'zuixin' into 'master'

Zuixin

See merge request !386
parents acf4c8e0 6eebbfee
......@@ -251,9 +251,9 @@ class TopicUtils(object):
]
if query is not None: # 搜索帖子
multi_fields = {
#'description': 200,
# 'description': 200,
'content': 300,
#'name': 400,
# 'name': 400,
'tag_name_list': 300,
}
query_fields = ['^'.join((k, str(v))) for (k, v) in multi_fields.items()]
......@@ -329,18 +329,18 @@ class TopicUtils(object):
'query': query,
'type': 'best_fields',
'operator': 'and',
'fields': ["content","tag_name_list"],
'fields': ["content", "tag_name_list"],
}
functions_list += [
{
"weight": 300,
"filter":{
"bool":{
"must":{
"filter": {
"bool": {
"must": {
"term": {"content_level": 6},
},
"minimum_should_match": 1,
"should":[
"should": [
{'multi_match': multi_match},
{"term": {"tag_list": tag_id}},
{"term": {"user_nick_name_pre": query.lower()}}
......@@ -973,7 +973,18 @@ class TopicUtils(object):
"order": "desc"
},
})
if sorts_by == TOPIC_SEARCH_SORT.TOPIC_ADD_TIME:
sort_rule.append({
"related_billboard.topic_add_createtime": {
"order": "desc",
"nested_path": "related_billboard",
"nested_filter": {
"term": {
"related_billboard.pictorial_id": pictorial_id
}
}
},
})
elif isinstance(sorts_by, list):
for sort_by in sorts_by:
if sort_by == TOPIC_SEARCH_SORT.ID_AEC:
......@@ -1067,6 +1078,7 @@ class TopicUtils(object):
}
},
})
logging.info("get picotirial:%s" % sort_rule)
return sort_rule
......@@ -1084,6 +1096,12 @@ class TopicUtils(object):
}
}
if 'pictorial_id' in filters.keys():
if sorts_by:
sorts = cls.process_sort(sorts_by, filters["pictorial_id"])
if sorts:
q["sort"] = sorts
else:
if sorts_by:
sorts = cls.process_sort(sorts_by, pictorial_id=None)
if sorts:
......
......@@ -60,6 +60,7 @@
"type":"nested",
"properties":{
"pictorial_id":{"type":"long"},
"topic_add_createtime":{"type":"long"},
"real_vote_cnt":{"type":"long"},
"virt_vote_cnt":{"type":"long"},
"total_vote_cnt":{"type":"long"}
......@@ -67,3 +68,6 @@
}
}
}
......@@ -60,6 +60,7 @@
"type":"nested",
"properties":{
"pictorial_id":{"type":"long"},
"topic_add_createtime":{"type":"long"},
"real_vote_cnt":{"type":"long"},
"virt_vote_cnt":{"type":"long"},
"total_vote_cnt":{"type":"long"}
......@@ -67,3 +68,6 @@
}
}
}
......@@ -60,6 +60,7 @@
"type":"nested",
"properties":{
"pictorial_id":{"type":"long"},
"topic_add_createtime":{"type":"long"},
"real_vote_cnt":{"type":"long"},
"virt_vote_cnt":{"type":"long"},
"total_vote_cnt":{"type":"long"}
......@@ -67,3 +68,6 @@
}
}
}
......@@ -60,6 +60,7 @@
"type":"nested",
"properties":{
"pictorial_id":{"type":"long"},
"topic_add_createtime":{"type":"long"},
"real_vote_cnt":{"type":"long"},
"virt_vote_cnt":{"type":"long"},
"total_vote_cnt":{"type":"long"}
......@@ -67,3 +68,6 @@
}
}
}
......@@ -60,6 +60,7 @@
"type":"nested",
"properties":{
"pictorial_id":{"type":"long"},
"topic_add_createtime":{"type":"long"},
"real_vote_cnt":{"type":"long"},
"virt_vote_cnt":{"type":"long"},
"total_vote_cnt":{"type":"long"}
......
......@@ -282,26 +282,28 @@ class Topic(models.Model):
def get_related_billboard(self):
try:
pictorial_ids = Topic.get_pictorial_id(self)
related_billboard_list = list()
for pictorial_id in pictorial_ids:
pictorials = PictorialTopic.objects.filter(topic_id=self.id).values("pictorial_id", "create_time")
for pictorial_id in pictorials:
query_result = TopicBillBoard.objects.filter(pictorial_id=pictorial_id,
query_result = TopicBillBoard.objects.filter(pictorial_id=pictorial_id.get('pictorial_id', None),
topic_id=self.id).values().first()
if query_result == None:
related_billboard_list.append({"pictorial_id": pictorial_id, "real_vote_cnt": 0,
"virt_vote_cnt": 0, "total_vote_cnt": 0})
related_billboard_list.append(
{"pictorial_id": pictorial_id.get('pictorial_id', None), "real_vote_cnt": 0,
"virt_vote_cnt": 0, "total_vote_cnt": 0,
"topic_add_createtime": int(
time.mktime(pictorial_id.get("create_time", None).timetuple()))})
else:
total_vote_cnt = int(query_result["virt_vote_cnt"]) + int(query_result["real_vote_cnt"])
related_billboard_list.append(
{"pictorial_id": query_result["pictorial_id"], "real_vote_cnt": query_result["real_vote_cnt"],
"virt_vote_cnt": query_result["virt_vote_cnt"], "total_vote_cnt": total_vote_cnt})
"virt_vote_cnt": query_result["virt_vote_cnt"], "total_vote_cnt": total_vote_cnt,
"topic_add_createtime": int(time.mktime(pictorial_id.get("create_time", None).timetuple()))})
logging.info("product_brand_info" % related_billboard_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