ciur / papermerge

Open Source Document Management System for Digital Archives (Scanned Documents)
https://papermerge.com
Apache License 2.0
2.55k stars 267 forks source link

Elasticsearch not working: You must specify a 'INDEX_NAME' in your settings for connection 'default' #478

Closed w4tzmann closed 2 years ago

w4tzmann commented 2 years ago

Description Using docker-compose with ghcr.io/papermerge/papermerge:latest and elasticsearch as search eninge are not working for me. After entering a word in the search bar an pressing Enter, nothing happens. papermerge backend container log entry:

ERROR 2022-09-14 13:56:32,648 log Internal Server Error: /api/search/ Traceback (most recent call last): File "/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, callback_kwargs) File "/venv/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, *kwargs) File "/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 84, in view return self.dispatch(request, args, kwargs) File "/venv/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch response = self.handle_exception(exc) File "/venv/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) File "/venv/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception raise exc File "/venv/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch response = handler(request, *args, kwargs) File "/app/papermerge/search/views.py", line 77, in get query_all = SearchQuerySet().filter(user=request.user) File "/venv/lib/python3.9/site-packages/haystack/query.py", line 25, in init self._determine_backend() File "/venv/lib/python3.9/site-packages/haystack/query.py", line 58, in _determine_backend self.query = connections[backend_alias].get_query() File "/venv/lib/python3.9/site-packages/haystack/backends/init.py", line 1100, in get_query return self.query(using=self.using) File "/venv/lib/python3.9/site-packages/haystack/backends/init.py", line 510, in init self.backend = connections[self._using].get_backend() File "/venv/lib/python3.9/site-packages/haystack/backends/init.py", line 1092, in get_backend self._backend = self.backend(self.using, self.options) File "/venv/lib/python3.9/site-packages/haystack/backends/elasticsearch7_backend.py", line 94, in init super().init(connection_alias, **connection_options) File "/venv/lib/python3.9/site-packages/haystack/backends/elasticsearch_backend.py", line 133, in init raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: You must specify a 'INDEX_NAME' in your settings for connection 'default'. [pid: 37|app: 0|req: 95/146] 172.18.0.7 () {58 vars in 1851 bytes} [Wed Sep 14 13:56:32 2022] GET /api/search/?q=Test => generated 145 bytes in 90 msecs (HTTP/1.1 500) 7 headers in 225 bytes (1 switches on core 0)

Switching to xapian and the search works like a charm.

Expected Search for the given words

Actual No Search

Info:

ciur commented 2 years ago

Thanks for opening bug report on this!

w4tzmann commented 2 years ago

I could fix this for me, with the following changes: https://github.com/papermerge/papermerge-core/pull/68

pm_search
ciur commented 2 years ago

PR was accepted and merged, thanks for your contribution!