Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add support for different ES backends on Heroku
Pacu2a48dab6fd65c
diff --git a/docs/elasticsearch.rst b/docs/elasticsearch.rstindex 2d7645bd14..b57adae851 100644--- a/docs/elasticsearch.rst+++ b/docs/elasticsearch.rst@@ -20,7 +20,7 @@ If you're deploying somewhere else, you can use one of following services:Environment variables----------------------``ELASTICSEARCH_URL``+``ELASTICSEARCH_URL`` or ``BONSAI_URL`` or ``SEARCHBOX_URL``URL to elasticsearch engine. If it's empty - search will be not available.**Example:** ``https://user:[email protected]:9200``diff --git a/saleor/core/context_processors.py b/saleor/core/context_processors.pyindex ece1339492..0ac69a8934 100644--- a/saleor/core/context_processors.py+++ b/saleor/core/context_processors.py@@ -31,7 +31,7 @@ def categories(request):def search_enabled(request):- return {'SEARCH_IS_ENABLED': bool(settings.ENABLE_SEARCH)}+ return {'SEARCH_IS_ENABLED': settings.ENABLE_SEARCH}def webpage_schema(request):@@ -43,7 +43,7 @@ def webpage_schema(request):'url': url,'name': site.name,'description': site.settings.description}- if bool(settings.ENABLE_SEARCH):+ if settings.ENABLE_SEARCH:data['potentialAction'] = {'@type': 'SearchAction','target': '%s%s?q={search_term}' % (url, reverse('search:search')),diff --git a/saleor/core/management/commands/populatedb.py b/saleor/core/management/commands/populatedb.pyindex 7cd6e24a7a..71c39c3e8a 100644--- a/saleor/core/management/commands/populatedb.py+++ b/saleor/core/management/commands/populatedb.py@@ -48,7 +48,7 @@ class Command(BaseCommand):cursor.execute('PRAGMA synchronous = OFF;')def populate_search_index(self):- if settings.ELASTICSEARCH_URL:+ if settings.ENABLE_SEARCH:call_command('search_index', '--rebuild', force=True)def handle(self, *args, **options):diff --git a/saleor/settings.py b/saleor/settings.pyindex a6f769e7d8..fa48339f89 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -357,14 +357,20 @@ WEBPACK_LOADER = {LOGOUT_ON_PASSWORD_CHANGE = False-ELASTICSEARCH_URL = os.environ.get('ELASTICSEARCH_URL', None)-ENABLE_SEARCH = bool(ELASTICSEARCH_URL)-if ELASTICSEARCH_URL:+ELASTICSEARCH_URL = os.environ.get('ELASTICSEARCH_URL')+SEARCHBOX_URL = os.environ.get('SEARCHBOX_URL')+BONSAI_URL = os.environ.get('BONSAI_URL')+# We'll support couple of elasticsearch add-ons, but finally we'll use single+# variable+ES_URL = ELASTICSEARCH_URL or SEARCHBOX_URL or BONSAI_URL+ENABLE_SEARCH = bool(ES_URL)++if ENABLE_SEARCH:INSTALLED_APPS.append('django_elasticsearch_dsl')ELASTICSEARCH_DSL = {'default': {- 'hosts': ELASTICSEARCH_URL+ 'hosts': ES_URL},}