summaryrefslogtreecommitdiffstats
path: root/forum_modules/pgfulltext/handlers.py
blob: 17fb176285d9573cf0b892111fa2e6d787a31eeb (plain)
1
2
3
4
5
6
7
8
9
10
11
from forum.models import Question

def question_search(keywords, orderby):
    return Question.objects.filter(deleted=False).extra(
                    select={
                        'ranking': "ts_rank_cd(tsv, plainto_tsquery(%s), 32)",
                    },
                    where=["tsv @@ plainto_tsquery(%s)"],
                    params=[keywords],
                    select_params=[keywords]
                ).order_by(orderby, '-ranking')