Commit f896baad authored by lixiaofang's avatar lixiaofang

修改排序逻辑

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