X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/5eeb9dace6068f83e2b70b5222cfab0c0a5e71eb..ed0e6512d2b49f22890362724101ae61ab191971:/apps/search/views.py?ds=sidebyside diff --git a/apps/search/views.py b/apps/search/views.py index dcd80b29f..fd5883ede 100644 --- a/apps/search/views.py +++ b/apps/search/views.py @@ -10,11 +10,11 @@ from django.utils.translation import ugettext as _ from catalogue.utils import split_tags from catalogue.models import Book, Tag, Fragment -from catalogue.fields import dumps from catalogue.views import JSONResponse from search import Search, JVM, SearchResult from lucene import StringReader from suggest.forms import PublishingSuggestForm +from time import sleep import re import enchant @@ -51,8 +51,21 @@ def did_you_mean(query, tokens): return query + JVM.attachCurrentThread() -search = Search() +_search = None + + +def get_search(): + global _search + + while _search is False: + sleep(1) + + if _search is None: + _search = False + _search = Search() + return _search def hint(request): @@ -61,6 +74,7 @@ def hint(request): return JSONResponse([]) JVM.attachCurrentThread() + search = get_search() hint = search.hint() try: tags = request.GET.get('tags', '') @@ -118,6 +132,7 @@ def main(request): return render_to_response('catalogue/search_too_short.html', {'prefix': query}, context_instance=RequestContext(request)) + search = get_search() # hint.tags(tag_list) # if book: # hint.books(book)