Skip to content

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

Use django_elasticsearch_dsl built-in index rebuild command when populating db

Jakub Draganekfa873f491b63
diff --git a/saleor/core/management/commands/populatedb.py b/saleor/core/management/commands/populatedb.py
index b31667d5a4..2dbfc3948c 100644
--- a/saleor/core/management/commands/populatedb.py
+++ b/saleor/core/management/commands/populatedb.py
@@ -47,7 +47,7 @@ class Command(BaseCommand):
cursor.execute('PRAGMA synchronous = OFF;')
def populate_search_index(self):
- call_command('update_index')
+ call_command('search_index', '--rebuild', force=True)
def handle(self, *args, **options):
self.make_database_faster()
diff --git a/saleor/settings.py b/saleor/settings.py
index 7e1aba8e81..392b9fff95 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -350,11 +350,10 @@ WEBPACK_LOADER = {
LOGOUT_ON_PASSWORD_CHANGE = False
-ENABLE_SEARCH = False
+ELASTICSEARCH_URL = os.environ.get('ELASTICSEARCH_URL', None)
+ENABLE_SEARCH = bool(ELASTICSEARCH_URL)
-ELASTICSEARCH_URL = os.environ.get('ELASTICSEARCH_URL')
if ELASTICSEARCH_URL:
- ENABLE_SEARCH = True
INSTALLED_APPS.append('django_elasticsearch_dsl')
ELASTICSEARCH_DSL = {
'default': {