X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/f109b7f6e35d54281f1edf4b684c49db621d36c5..9e65086e2b3ab261138a95bfe8b2a17947c630dd:/apps/search/views.py?ds=inline diff --git a/apps/search/views.py b/apps/search/views.py index 5ed610705..fc14b067d 100644 --- a/apps/search/views.py +++ b/apps/search/views.py @@ -8,7 +8,7 @@ from django.views.decorators import cache from catalogue.utils import get_random_hash from catalogue.models import Book, Tag from catalogue import forms -from search import MultiSearch, JVM +from search import MultiSearch, JVM, SearchResult def main(request): @@ -19,9 +19,13 @@ def main(request): results = None if 'q' in request.GET: toks = srch.get_tokens(request.GET['q']) - results = srch.search_perfect(toks) + srch.search_everywhere(toks) - results.sort(lambda a, b: cmp(a[0], b[0]) < 0) - print("searched, results are: %s\n" % results) + results = SearchResult.aggregate(srch.search_perfect_book(toks), + srch.search_perfect_parts(toks), + srch.search_everywhere(toks)) + results.sort(reverse=True) + + for r in results: + print r.parts return render_to_response('newsearch/search.html', {"results": results}, context_instance=RequestContext(request))