From ca2cb694d0dbd70c550c8dc9e69a578e9fe6fd4e Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Fri, 18 Dec 2020 00:10:16 +0100 Subject: [PATCH] code style --- src/documents/index.py | 13 ++++++++----- src/documents/views.py | 3 +-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/documents/index.py b/src/documents/index.py index 7d022182f..fdf7d7041 100644 --- a/src/documents/index.py +++ b/src/documents/index.py @@ -136,11 +136,14 @@ def query_page(ix, page, querystring, more_like_doc_id, more_like_doc_content): if more_like_doc_id: docnum = searcher.document_number(id=more_like_doc_id) - kts = searcher.key_terms_from_text('content', more_like_doc_content, numterms=20, - model=classify.Bo1Model, normalize=False) - more_like_q = query.Or([query.Term('content', word, boost=weight) - for word, weight in kts]) - result_page = searcher.search_page(more_like_q, page, filter=str_q, mask={docnum}) + kts = searcher.key_terms_from_text( + 'content', more_like_doc_content, numterms=20, + model=classify.Bo1Model, normalize=False) + more_like_q = query.Or( + [query.Term('content', word, boost=weight) + for word, weight in kts]) + result_page = searcher.search_page( + more_like_q, page, filter=str_q, mask={docnum}) elif str_q: result_page = searcher.search_page(str_q, page) else: diff --git a/src/documents/views.py b/src/documents/views.py index 1f5489999..54d0de3f6 100755 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -370,8 +370,7 @@ class SearchView(APIView): page = 1 try: - with index.query_page(self.ix, page, query, more_like_id, more_like_content) as (result_page, - corrected_query): + with index.query_page(self.ix, page, query, more_like_id, more_like_content) as (result_page, corrected_query): # NOQA: E501 return Response( {'count': len(result_page), 'page': result_page.pagenum,