From 938499706ce8a1ff01234cd833dd1c044cc92e1d Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Fri, 27 Nov 2020 13:59:24 +0100 Subject: [PATCH] fixed an issue with the search api opening the index on import (that's way too early.) --- src/documents/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/documents/views.py b/src/documents/views.py index 287fb114c..96b413d67 100755 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -202,7 +202,9 @@ class SearchView(APIView): permission_classes = (IsAuthenticated,) - ix = index.open_index() + def __init__(self, *args, **kwargs): + super(SearchView, self).__init__(*args, **kwargs) + self.ix = index.open_index() def add_infos_to_hit(self, r): doc = Document.objects.get(id=r['id']) @@ -241,7 +243,9 @@ class SearchAutoCompleteView(APIView): permission_classes = (IsAuthenticated,) - ix = index.open_index() + def __init__(self, *args, **kwargs): + super(SearchAutoCompleteView, self).__init__(*args, **kwargs) + self.ix = index.open_index() def get(self, request, format=None): if 'term' in request.query_params: