Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Filter published products in storefront search

Jakub Draganekff8e83e8ddb0
diff --git a/saleor/search/backends/postgresql.py b/saleor/search/backends/postgresql.py
index eb02a440c4..16974d5a9e 100644
--- a/saleor/search/backends/postgresql.py
+++ b/saleor/search/backends/postgresql.py
@@ -5,5 +5,8 @@ from django.contrib.postgres.search import TrigramSimilarity
def search(phrase):
name_sim = TrigramSimilarity('name', phrase)
+ published = Q(is_published=True)
+ ft_in_description = Q(description__search=phrase)
+ name_similar = Q(name_sim__gt=0.2)
return Product.objects.annotate(name_sim=name_sim).filter(
- Q(description__search=phrase) | Q(name_sim__gt=0.1))
+ (ft_in_description | name_similar) & published)