summaryrefslogtreecommitdiffstats
path: root/forum_modules/pgfulltext/handlers.py
blob: f4a7a3b2ee63c9911214630169d1d86e4c4cde7f (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')