aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/search.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-02-08 14:35:39 -0800
committerBryan Newbold <bnewbold@robocracy.org>2022-02-09 17:35:50 -0800
commit6244c06abf8488fff87b30cb0a8433592f1f5d24 (patch)
treee125add62f7104de1b5304b035481d0d5997e774 /python/fatcat_web/search.py
parentfa1ad78cd0e00f524221f972889ee32373d7b94e (diff)
downloadfatcat-6244c06abf8488fff87b30cb0a8433592f1f5d24.tar.gz
fatcat-6244c06abf8488fff87b30cb0a8433592f1f5d24.zip
container search: iterate on SERP page (including stats)
Diffstat (limited to 'python/fatcat_web/search.py')
-rw-r--r--python/fatcat_web/search.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py
index 8cbe09f6..2a3515d4 100644
--- a/python/fatcat_web/search.py
+++ b/python/fatcat_web/search.py
@@ -178,7 +178,7 @@ def do_container_search(query: GenericQuery, deep_page_limit: int = 2000) -> Sea
search = Search(using=app.es_client, index=app.config["ELASTICSEARCH_CONTAINER_INDEX"])
- search = search.query(
+ basic_query = Q(
"query_string",
query=query.q,
default_operator="AND",
@@ -188,6 +188,20 @@ def do_container_search(query: GenericQuery, deep_page_limit: int = 2000) -> Sea
fields=["biblio"],
)
+ search = search.query(
+ "boosting",
+ positive=Q(
+ "bool",
+ must=basic_query,
+ should=[
+ Q("range", releases_total={"gte": 500}),
+ Q("range", releases_total={"gte": 5000}),
+ ],
+ ),
+ negative=Q("term", releases_total=0),
+ negative_boost=0.5,
+ )
+
# Sanity checks
limit = min((int(query.limit or 25), 100))
offset = max((int(query.offset or 0), 0))