diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-05-21 19:51:01 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-05-21 19:51:01 -0700 |
commit | 0063be61247aa4ea697568ce9741f6857b80d595 (patch) | |
tree | f49648feb028549774df205f79e420a08977ad1b /fatcat_scholar | |
parent | 44fade946357f9c73b39321ed775cb2a3687333b (diff) | |
download | fatcat-scholar-0063be61247aa4ea697568ce9741f6857b80d595.tar.gz fatcat-scholar-0063be61247aa4ea697568ce9741f6857b80d595.zip |
implement crude availability filter
Diffstat (limited to 'fatcat_scholar')
-rw-r--r-- | fatcat_scholar/search.py | 11 |
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 |