]> git.openstreetmap.org Git - osqa.git/blob - forum_modules/pgfulltext/handlers.py
45ab2e781888d0118dfbde9457868e28fc73ebd1
[osqa.git] / forum_modules / pgfulltext / handlers.py
1 from forum.models import Question
2
3 def question_search(keywords):
4     return Question.objects.extra(
5                     select={
6                         'ranking': "ts_rank_cd(tsv, plainto_tsquery(%s), 32)",
7                     },
8                     where=["tsv @@ plainto_tsquery(%s)"],
9                     params=[keywords],
10                     select_params=[keywords]
11                 ).order_by('-ranking')