Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Implement simple storefront full text search in postgres
Jakub Draganek7feec6ceebe7
diff --git a/saleor/search/backends/postgresql.py b/saleor/search/backends/postgresql.pyindex ebdae2b7bf..f43269014d 100644--- a/saleor/search/backends/postgresql.py+++ b/saleor/search/backends/postgresql.py@@ -1,5 +1,7 @@from ...product.models import Product+from django.contrib.postgres.search import SearchVectordef search(phrase):- return Product.objects.none()+ obj = Product.objects.annotate(search=SearchVector('name', 'description'))+ return obj.filter(search=phrase)diff --git a/saleor/settings.py b/saleor/settings.pyindex 7f0388a4cd..d6bdc4a9cf 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -361,9 +361,9 @@ LOGOUT_ON_PASSWORD_CHANGE = FalseDB_SEARCH_ENABLED = TruePREFER_DB_SEARCH = False # prefer db backend over elasticsearch-ELASTICSEARCH_URL = os.environ.get('ELASTICSEARCH_URL')-SEARCHBOX_URL = os.environ.get('SEARCHBOX_URL')-BONSAI_URL = os.environ.get('BONSAI_URL')+ELASTICSEARCH_URL = os.environ.get('ELASTICSEARCH_URL', None)+SEARCHBOX_URL = os.environ.get('SEARCHBOX_URL', None)+BONSAI_URL = os.environ.get('BONSAI_URL', None)# We'll support couple of elasticsearch add-ons, but finally we'll use single# variable