code style

This commit is contained in:
jonaswinkler 2020-12-18 00:10:16 +01:00
parent cea34211b6
commit ca2cb694d0
2 changed files with 9 additions and 7 deletions

View File

@ -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:

View File

@ -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,