From 6244c06abf8488fff87b30cb0a8433592f1f5d24 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 8 Feb 2022 14:35:39 -0800 Subject: container search: iterate on SERP page (including stats) --- python/fatcat_web/search.py | 16 +++++- python/fatcat_web/templates/container_search.html | 3 +- python/fatcat_web/templates/entity_macros.html | 63 ++++++++++++++++++++--- 3 files changed, 72 insertions(+), 10 deletions(-) (limited to 'python') 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)) diff --git a/python/fatcat_web/templates/container_search.html b/python/fatcat_web/templates/container_search.html index 0eeed55e..f091fc3b 100644 --- a/python/fatcat_web/templates/container_search.html +++ b/python/fatcat_web/templates/container_search.html @@ -34,9 +34,10 @@ {% if found.results %} {{ search_macros.top_results(query, found) }} +
{% for entity in found.results %} - {{ entity_macros.container_search_result_row(entity) }} + {{ entity_macros.container_search_result_row(entity, show_stats=True) }} {% endfor %} {% if found.results|length > 8 %} diff --git a/python/fatcat_web/templates/entity_macros.html b/python/fatcat_web/templates/entity_macros.html index 9b419c41..b801f3c5 100644 --- a/python/fatcat_web/templates/entity_macros.html +++ b/python/fatcat_web/templates/entity_macros.html @@ -267,23 +267,70 @@ {% endmacro %} -{% macro container_search_result_row(entity) -%} +{% macro container_search_result_row(entity, show_stats=False) -%}
-

+ {% if show_stats %} +
+ {% if entity.releases_total %} + ~{{ "{:,}".format(entity.releases_total) }} releases + {% elif entity.releases_total == 0 %} + (not indexed) + {% endif %} + {% if entity.releases_total %} + {{ preservation_bar({'bright': entity.preservation_bright, 'dark': entity.preservation_dark, 'none': entity.preservation_none, 'total': entity.releases_total}) }} + {% endif %} +
+ {% endif %} +

{{ entity['name'] }} - {% if entity.is_oa %}{% endif %}

+ {% if entity.original_name %} + {{ entity.original_name }}
+ {% endif %} {% if entity.publisher %} -
{{ entity.publisher }}
+ {{ entity.publisher }} +
{% endif %} {% if entity.issnl %} - issn:{{ entity.issnl }} + issnl:{{ entity.issnl }}   + {% endif %} + {% if entity.wikidata_qid %} + wikidata:{{ entity.wikidata_qid }}   + {% endif %} + {% if entity.dblp_prefix %} + dblp:{{ entity.dblp_prefix }}   + {% endif %} + {% if entity.ia_sim_collection %} + [archive.org]   + {% elif entity.sim_pubid %} + [archive.org]   + {% endif %} + {# too much clutter + {% if entity.country_code %} + country:{{ entity.country_code }}   + {% endif %} + {% for lang in entity.languages %} + lang:{{ lang }}   + {% endfor %} + {% if entity.any_kbart %} + [KBART]   + {% endif %} +
+ #} + {% if entity.in_doaj %} + [DOAJ]   + {% endif %} + {% if entity.in_road %} + [ROAD]   + {% endif %} + {% if entity.is_oa and not (entity.in_doaj or entity.in_road) %} + [open-access]   {% endif %} - {% if entity.container_type %} -  {{ entity.container_type }} + {% if entity.container_type and entity.container_type != "journal" %} + [{{ entity.container_type }}]   {% endif %} {% if entity.publication_status and entity.publication_status != "active" %} -  {{ entity.publication_status }} + {{ entity.publication_status }}   {% endif %}
{% endmacro %} -- cgit v1.2.3