aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_scholar
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-08-06 13:57:55 -0700
committerBryan Newbold <bnewbold@archive.org>2020-08-06 13:58:00 -0700
commitd78f32eb541445a15a24d117347bd4aeedbb670f (patch)
treedf5cb3db9889c36f3cd476a2f568c0d6d0939543 /fatcat_scholar
parent2502d5affdd097bf52073b393cdb97285d023e5d (diff)
downloadfatcat-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')
-rw-r--r--fatcat_scholar/search.py22
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",