added company_name as a vector in product search

This commit is contained in:
Sam
2021-03-05 10:41:25 +00:00
parent f81bbee4e6
commit cdb18ea157
2 changed files with 4 additions and 2 deletions

View File

@@ -114,12 +114,12 @@ def find_related_products_v6(keyword, shipping_cost=None, discount=None, categor
allow filtering by:
- shipping cost
"""
vector = SearchVector('name') + SearchVector('description') + SearchVector('tags__label') + SearchVector('attributes__label') + SearchVector('category__name')
vector = SearchVector('name') + SearchVector('description') + SearchVector('tags__label') + SearchVector('attributes__label') + SearchVector('category__label') + SearchVector('company__company_name')
query = SearchQuery(keyword)
products_qs = Product.objects.annotate(
rank=SearchRank(vector, query)
).filter(rank__gt=0.05) # removed order_by because its lost in casting
).filter(rank__gt=0.05)
# filter by category
if category is not None: