changing the way search workd to accommodate for georestrictions

This commit is contained in:
Sam
2021-03-11 11:33:12 +00:00
parent 5178eb9722
commit 9794ab1f18
3 changed files with 22 additions and 1 deletions

View File

@@ -144,7 +144,12 @@ def ranked_product_search(keyword, shipping_cost=None, discount=None, category=N
- georesult
"""
vector = SearchVector('name') + SearchVector('description') + SearchVector('tags__label') + SearchVector('attributes__label') + SearchVector('category__label') + SearchVector('company__company_name')
query = SearchQuery(keyword)
query_string = ''
for word in keyword:
query_string += f" | '{keyword}' "
query = SearchQuery(query_string)
products_qs = Product.objects.annotate(
rank=SearchRank(vector, query)