aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-02-09 00:23:04 -0800
committerBryan Newbold <bnewbold@robocracy.org>2022-02-09 17:35:50 -0800
commit9ab3cd54aa039393d294cdc85871353651c35576 (patch)
treeafaecc973b09ec236cb0401bfe6f588a7c3a62ed /python
parent6976b6868cdf0628aa79d47aab4e889a9ccfc0dc (diff)
downloadfatcat-9ab3cd54aa039393d294cdc85871353651c35576.tar.gz
fatcat-9ab3cd54aa039393d294cdc85871353651c35576.zip
search: improve container_id handling
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_web/search.py33
1 files changed, 6 insertions, 27 deletions
diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py
index 2a3515d4..9e9376cc 100644
--- a/python/fatcat_web/search.py
+++ b/python/fatcat_web/search.py
@@ -44,16 +44,6 @@ class ReleaseQuery:
query_str = args.get("q") or "*"
- container_id = args.get("container_id")
- # TODO: as filter, not in query string
- if container_id:
- query_str += ' container_id:"{}"'.format(container_id)
-
- # TODO: where are container_issnl queries actually used?
- issnl = args.get("container_issnl")
- if issnl and query_str:
- query_str += ' container_issnl:"{}"'.format(issnl)
-
offset = args.get("offset", "0")
offset = max(0, int(offset)) if offset.isnumeric() else 0
@@ -61,7 +51,7 @@ class ReleaseQuery:
q=query_str,
offset=offset,
fulltext_only=bool(args.get("fulltext_only")),
- container_id=container_id,
+ container_id=args.get("container_id"),
recent=bool(args.get("recent")),
exclude_stubs=bool(args.get("exclude_stubs")),
)
@@ -263,6 +253,9 @@ def do_release_search(query: ReleaseQuery, deep_page_limit: int = 2000) -> Searc
],
)
+ if query.container_id:
+ search = search.filter("term", container_id=query.container_id)
+
search = search.query(
"boosting",
positive=Q(
@@ -657,11 +650,7 @@ def get_elastic_preservation_by_year(query: ReleaseQuery) -> List[Dict[str, Any]
"biblio",
],
)
- if query.container_id:
- search = search.filter(
- "term",
- container_id=query.container_id,
- )
+ search = search.filter("term", container_id=query.container_id)
if query.exclude_stubs:
search = search.query(
"bool",
@@ -923,17 +912,7 @@ def get_elastic_preservation_by_type(query: ReleaseQuery) -> List[dict]:
],
)
if query.container_id:
- search = search.query(
- "bool",
- filter=[
- Q(
- "bool",
- must=[
- Q("match", container_id=query.container_id),
- ],
- ),
- ],
- )
+ search = search.filter("term", container_id=query.container_id)
if query.recent:
date_today = datetime.date.today()
start_date = str(date_today - datetime.timedelta(days=60))