From 0063be61247aa4ea697568ce9741f6857b80d595 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 21 May 2020 19:51:01 -0700 Subject: implement crude availability filter --- fatcat_scholar/search.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'fatcat_scholar') 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 -- cgit v1.2.3