aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_scholar/search.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-05-21 19:51:01 -0700
committerBryan Newbold <bnewbold@archive.org>2020-05-21 19:51:01 -0700
commit0063be61247aa4ea697568ce9741f6857b80d595 (patch)
treef49648feb028549774df205f79e420a08977ad1b /fatcat_scholar/search.py
parent44fade946357f9c73b39321ed775cb2a3687333b (diff)
downloadfatcat-scholar-0063be61247aa4ea697568ce9741f6857b80d595.tar.gz
fatcat-scholar-0063be61247aa4ea697568ce9741f6857b80d595.zip
implement crude availability filter
Diffstat (limited to 'fatcat_scholar/search.py')
-rw-r--r--fatcat_scholar/search.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py
index aeb089d..c78b10c 100644
--- a/fatcat_scholar/search.py
+++ b/fatcat_scholar/search.py
@@ -121,6 +121,17 @@ def do_fulltext_search(query: FulltextQuery, deep_page_limit: int = 2000) -> Ful
else:
raise ValueError(f"Unknown 'filter_time' parameter value: '{query.filter_time}'")
+ # availability filters
+ if query.filter_availability == "oa":
+ # TODO: real OA filter/flag
+ search = search.filter("exists", field="license_slug")
+ elif query.filter_availability == "fulltext":
+ search = search.filter("terms", access_type=["wayback", "ia_file", "ia_sim"])
+ elif query.filter_availability == "everything" or query.filter_availability == None:
+ pass
+ else:
+ raise ValueError(f"Unknown 'filter_availability' parameter value: '{query.filter_availability}'")
+
# we combined several queries to improve scoring.
# this query use the fancy built-in query string parser