From d78f32eb541445a15a24d117347bd4aeedbb670f Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 6 Aug 2020 13:57:55 -0700 Subject: special case '*' queries More/better query parsing in the client could detect if this was a "filter only" query and do the same kind of optimization. --- fatcat_scholar/search.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py index edff907..c9c264e 100644 --- a/fatcat_scholar/search.py +++ b/fatcat_scholar/search.py @@ -197,12 +197,22 @@ def do_fulltext_search( ], ) - search = search.query( - "boosting", - positive=Q("bool", must=basic_fulltext, should=[has_fulltext],), - negative=poor_metadata, - negative_boost=0.5, - ) + if query.filter_availability == "fulltext" or query.filter_availability is None: + base_query = basic_fulltext + else: + base_query = Q("bool", must=basic_fulltext, should=[has_fulltext]) + + if query.q == "*": + search = search.query("match_all") + search = search.sort("_doc") + else: + search = search.query( + "boosting", + positive=base_query, + negative=poor_metadata, + negative_boost=0.5, + ) + search = search.highlight( "abstracts.body", "fulltext.body", -- cgit v1.2.3