Commit f896baad authored by lixiaofang's avatar lixiaofang

修改排序逻辑

parent a298c7b8
...@@ -875,7 +875,7 @@ class TopicUtils(object): ...@@ -875,7 +875,7 @@ class TopicUtils(object):
return nf return nf
@classmethod @classmethod
def process_sort(cls, sorts_by): def process_sort(cls, sorts_by, pictorial_id):
"""处理排序部分。""" """处理排序部分。"""
sort_rule = [] sort_rule = []
...@@ -932,7 +932,13 @@ class TopicUtils(object): ...@@ -932,7 +932,13 @@ class TopicUtils(object):
sort_rule.append({ sort_rule.append({
"related_billboard.real_vote_cnt": { "related_billboard.real_vote_cnt": {
"order": "asc", "order": "asc",
"nested_path": "related_billboard" "nested_path": "related_billboard",
"missing": "_last",
"nested_filter": {
"term": {
"related_billboard.pictorial_id": pictorial_id
}
}
}, },
}) })
...@@ -940,24 +946,42 @@ class TopicUtils(object): ...@@ -940,24 +946,42 @@ class TopicUtils(object):
sort_rule.append({ sort_rule.append({
"related_billboard.real_vote_cnt": { "related_billboard.real_vote_cnt": {
"order": "desc", "order": "desc",
"nested_path": "related_billboard" "nested_path": "related_billboard",
"missing": "_last",
"nested_filter": {
"term": {
"related_billboard.pictorial_id": pictorial_id
}
}
}, },
}) })
elif sort_by == TOPIC_SEARCH_SORT.VIRT_VOTE_AEC: elif sort_by == TOPIC_SEARCH_SORT.VIRT_VOTE_AEC:
sort_rule.append({ sort_rule.append({
"related_billboard.virt_vote_cnt": { "related_billboard.virt_vote_cnt": {
"order": "asc", "order": "asc",
"nested_path": "related_billboard" "nested_path": "related_billboard",
"missing": "_last",
"nested_filter": {
"term": {
"related_billboard.pictorial_id": pictorial_id
}
}
}, },
}) })
elif sort_by == TOPIC_SEARCH_SORT.VIRT_VOTE_DESC: elif sort_by == TOPIC_SEARCH_SORT.VIRT_VOTE_DESC:
sort_rule.append({ sort_rule.append({
"related_billboard.virt_vote_cnt": { "related_billboard.virt_vote_cnt": {
"order": "desc", "order": "desc",
"nested_path": "related_billboard" "nested_path": "related_billboard",
"missing": "_last",
"nested_filter": {
"term": {
"related_billboard.pictorial_id": pictorial_id
}
}
}, },
}) })
return sort_rule return sort_rule
@classmethod @classmethod
...@@ -974,7 +998,7 @@ class TopicUtils(object): ...@@ -974,7 +998,7 @@ class TopicUtils(object):
} }
if sorts_by: if sorts_by:
sorts = cls.process_sort(sorts_by) sorts = cls.process_sort(sorts_by,pictorial_id=None)
if sorts: if sorts:
q["sort"] = sorts q["sort"] = sorts
......
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