diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2022-02-08 14:35:39 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2022-02-09 17:35:50 -0800 |
commit | 6244c06abf8488fff87b30cb0a8433592f1f5d24 (patch) | |
tree | e125add62f7104de1b5304b035481d0d5997e774 | |
parent | fa1ad78cd0e00f524221f972889ee32373d7b94e (diff) | |
download | fatcat-6244c06abf8488fff87b30cb0a8433592f1f5d24.tar.gz fatcat-6244c06abf8488fff87b30cb0a8433592f1f5d24.zip |
container search: iterate on SERP page (including stats)
-rw-r--r-- | python/fatcat_web/search.py | 16 | ||||
-rw-r--r-- | python/fatcat_web/templates/container_search.html | 3 | ||||
-rw-r--r-- | python/fatcat_web/templates/entity_macros.html | 63 |
3 files changed, 72 insertions, 10 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)) 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) }} + <br clear="all"> {% 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) -%} <div> - <h4 style="margin-top: 1em; margin-bottom: 4px; font-size: 1.1em;"> + {% if show_stats %} + <div style="float: right; margin-left: 0.5em; margin-top:0px; width: 150px; text-align: right;"> + {% if entity.releases_total %} + <b>~{{ "{:,}".format(entity.releases_total) }}</b> releases + {% elif entity.releases_total == 0 %} + <i>(not indexed)</i> + {% endif %} + {% if entity.releases_total %} + {{ preservation_bar({'bright': entity.preservation_bright, 'dark': entity.preservation_dark, 'none': entity.preservation_none, 'total': entity.releases_total}) }} + {% endif %} + </div> + {% endif %} + <h4 style="margin-top: 1em; margin-bottom: 0em; font-size: 1.1em;"> <a href="/container/{{ entity.ident }}" style="color: #2224c7;">{{ entity['name'] }}</a> - {% if entity.is_oa %}<i class="icon unlock orange small"></i>{% endif %} </h4> + {% if entity.original_name %} + <i>{{ entity.original_name }}</i></br> + {% endif %} {% if entity.publisher %} - <h5 style="margin-top: 4px; margin-bottom: 0px; font-size: 1em;">{{ entity.publisher }}</h5> + <a href="/container/search?q=publisher:%22{{ entity.publisher }}%22" style="color: black; margin-top: 0em;">{{ entity.publisher }}</a> + <br> {% endif %} {% if entity.issnl %} - <a href="https://portal.issn.org/resource/ISSN/{{entity.issnl }}" style="color: green;">issn:{{ entity.issnl }}</a> + <a href="https://portal.issn.org/resource/ISSN/{{ entity.issnl }}" style="color: green;">issnl:{{ entity.issnl }}</a> + {% endif %} + {% if entity.wikidata_qid %} + <a href="https://wikidata.org/wiki/{{ entity.wikidata_qid }}" style="color: green;">wikidata:{{ entity.wikidata_qid }}</a> + {% endif %} + {% if entity.dblp_prefix %} + <a href="https://dblp.org/db/{{ entity.dblp_prefix }}/index.html" style="color: green;">dblp:{{ entity.dblp_prefix }}</a> + {% endif %} + {% if entity.ia_sim_collection %} + <a href="https://archive.org/details/{{ entity.ia_sim_collection }}" style="color: green;">[archive.org]</a> + {% elif entity.sim_pubid %} + <a href="https://archive.org/search.php?query=sim_pubid%3A{{ entity.sim_pubid }}%20mediatype%3Acollection" style="color: green;">[archive.org]</a> + {% endif %} + {# too much clutter + {% if entity.country_code %} + <span style="color: black;">country:{{ entity.country_code }}</span> + {% endif %} + {% for lang in entity.languages %} + <span style="color: black;">lang:{{ lang }}</span> + {% endfor %} + {% if entity.any_kbart %} + <span style="color: black;">[KBART]</span> + {% endif %} + <br> + #} + {% if entity.in_doaj %} + <span style="color: #c54e00;">[DOAJ]</span> + {% endif %} + {% if entity.in_road %} + <span style="color: #c54e00;">[ROAD]</span> + {% endif %} + {% if entity.is_oa and not (entity.in_doaj or entity.in_road) %} + <span style="color: #c54e00;">[open-access]</span> {% endif %} - {% if entity.container_type %} - {{ entity.container_type }} + {% if entity.container_type and entity.container_type != "journal" %} + <b>[{{ entity.container_type }}]</b> {% endif %} {% if entity.publication_status and entity.publication_status != "active" %} - {{ entity.publication_status }} + <span style="color: brown;">{{ entity.publication_status }}</span> {% endif %} </div> {% endmacro %} |