diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-08-06 13:57:55 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-08-06 13:58:00 -0700 |
commit | d78f32eb541445a15a24d117347bd4aeedbb670f (patch) | |
tree | df5cb3db9889c36f3cd476a2f568c0d6d0939543 /fatcat_scholar/search.py | |
parent | 2502d5affdd097bf52073b393cdb97285d023e5d (diff) | |
download | fatcat-scholar-d78f32eb541445a15a24d117347bd4aeedbb670f.tar.gz fatcat-scholar-d78f32eb541445a15a24d117347bd4aeedbb670f.zip |
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.
Diffstat (limited to 'fatcat_scholar/search.py')
-rw-r--r-- | fatcat_scholar/search.py | 22 |
1 files 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", |