hw 6-7 some fixes
This commit is contained in:
1 parent
34630657b8
commit
3080e5b5b6
8 files changed
+67
-65
No files matched your search
+6
-3
@@ -112,11 +112,14 @@ def search(request):
|
||||
if not query_text:
|
||||
return JsonResponse({'results': []})
|
||||
|
||||
vector = SearchVector('title', 'body')
|
||||
query = SearchQuery(query_text)
|
||||
vector = (
|
||||
SearchVector('title', weight='A') +
|
||||
SearchVector('body', weight='B')
|
||||
)
|
||||
query = SearchQuery(query_text, search_type='websearch')
|
||||
questions = Question.objects.annotate(
|
||||
rank=SearchRank(vector, query)
|
||||
).filter(rank__gte=0.1).order_by('-rank')[:10]
|
||||
).filter(rank__gt=0).order_by('-rank')[:10]
|
||||
|
||||
results = [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user