hi
i keep getting an error in search backends
Exception Type: InvalidSearchBackendError
Exception Value: Could not find backend 'default': No module named 'default'
and i don't know how to fix it!
What's your SEARCH_BACKENDS setting?
SEARCH_BACKENDS = {
'default': {
'BACKEND': 'saleor.search.backends.elasticsearch5',
'URLS': [ES_URL],
'INDEX': os.environ.get('ELASTICSEARCH_INDEX_NAME', 'storefront'),
'TIMEOUT': 5,
'AUTO_UPDATE': True},
'dashboard': {
'BACKEND': 'saleor.search.backends.dashboard',
'URLS': [ES_URL],
'INDEX': os.environ.get('ELASTICSEARCH_INDEX_NAME', 'storefront'),
'TIMEOUT': 5,
'AUTO_UPDATE': False}
}
Are you sure it's actually set? The exception seems to indicate that the setting is empty or at least missing the default key?
yes i'm sure. does this method somehow use uwsgi package? because that package is missing from my packages and unfortunately i can't install it! i'm using windows
No, it shouldn't touch uwsgi. I'd suggest starting with checking the value returned by get_search_backend_config in saleor/search/backends/__init__.py.
get_search_backend_config returned an empty dict 馃槰
Unless you've modified this code in a way, by default it returns the above setting. This does not seem right. Let me know if you determine why it ends up being empty or if you have any additional hints I could use to direct you to other parts of code.
in setting.py:
ES_URL = ELASTICSEARCH_URL or SEARCHBOX_URL or BONSAI_URL or ''
if ES_URL
and if i change ES_URL to True, get_search_backend_config return the right dict.
i think the problem is one of these ELASTICSEARCH_URL or SEARCHBOX_URL or BONSAI_URL is not set somehow. can i ask what are these urls and how they initialized?
Hmm, if neither is set then search should disable itself and you should not be getting this error. What action are you attempting when you get this error? Could you paste the full stack trace from the error page?
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/search/?q=sample
Django Version: 1.11.5
Python Version: 3.6.1
Installed Applications:
['storages',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sitemaps',
'django.contrib.sites',
'django.contrib.staticfiles',
'django.contrib.auth',
'django.contrib.postgres',
'django.forms',
'saleor.userprofile',
'saleor.discount',
'saleor.product',
'saleor.cart',
'saleor.checkout',
'saleor.core',
'saleor.graphql',
'saleor.order',
'saleor.dashboard',
'saleor.shipping',
'saleor.search',
'saleor.site',
'saleor.data_feeds',
'versatileimagefield',
'babeldjango',
'bootstrap3',
'django_prices',
'django_prices_openexchangerates',
'graphene_django',
'mptt',
'payments',
'webpack_loader',
'social_django',
'django_countries',
'django_filters',
'django_celery_results']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'babeldjango.middleware.LocaleMiddleware',
'saleor.core.middleware.DiscountMiddleware',
'saleor.core.middleware.GoogleAnalytics',
'saleor.core.middleware.CountryMiddleware',
'saleor.core.middleware.CurrencyMiddleware',
'saleor.core.middleware.ClearSiteCacheMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware']
Traceback:
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\module_loading.py" in import_string
During handling of the above exception (not enough values to unpack (expected 2, got 1)), another exception occurred:
File "E:\Programming\Python\saleor\saleor\search\backends__init__.py" in import_backend
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\module_loading.py" in import_string
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\six.py" in reraise
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\module_loading.py" in import_string
During handling of the above exception (default doesn't look like a module path), another exception occurred:
File "E:\Programming\Python\saleor\saleor\search\backends__init__.py" in get_search_backend
File "E:\Programming\Python\saleor\saleor\search\backends__init__.py" in import_backend
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\six.py" in reraise
File "E:\Programming\Python\saleor\saleor\search\backends__init__.py" in import_backend
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\module_loading.py" in import_string
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\six.py" in reraise
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\module_loading.py" in import_string
During handling of the above exception (No module named 'default'), another exception occurred:
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\exception.py" in inner
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py" in _legacy_get_response
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response
File "C:\Users\MehrdadAppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response
File "E:\Programming\Python\saleor\saleor\search\views.py" in search
File "E:\Programming\Python\saleor\saleor\search\forms.py" in search
File "E:\Programming\Python\saleor\saleor\search\backends__init__.py" in get_search_backend
Exception Type: InvalidSearchBackendError at /search/
Exception Value: Could not find backend 'default': No module named 'default'
Ok, that's a bug. Search should be disabled. Thank you for getting to the bottom of this.
@salwator This seems related to your current work on the search backends. We should add some safeguards so search is not reachable when not configured.
Most helpful comment
Ok, that's a bug. Search should be disabled. Thank you for getting to the bottom of this.