diff --git a/catalog/search/typesense.py b/catalog/search/typesense.py index ed500fa5..9c94e6cd 100644 --- a/catalog/search/typesense.py +++ b/catalog/search/typesense.py @@ -5,6 +5,7 @@ from typesense.exceptions import ObjectNotFound from django.conf import settings from django.db.models.signals import post_save, post_delete from catalog.models import Item +from pprint import pprint INDEX_NAME = "catalog" SEARCHABLE_ATTRIBUTES = [ @@ -249,6 +250,7 @@ class Indexer: "per_page": SEARCH_PAGE_SIZE, "query_by": ",".join(SEARCHABLE_ATTRIBUTES), "filter_by": filters, + # "facet_by": "category", "sort_by": "_text_match:desc,rating_count:desc" # 'facetsDistribution': ['_class'], # 'sort_by': None, @@ -257,7 +259,7 @@ class Indexer: try: r = cls.instance().collections[INDEX_NAME].documents.search(options) - print(r) + # pprint(r) results.items = list( [ x diff --git a/catalog/templates/fetch_pending.html b/catalog/templates/fetch_pending.html index a7189e93..03173f4d 100644 --- a/catalog/templates/fetch_pending.html +++ b/catalog/templates/fetch_pending.html @@ -21,7 +21,7 @@
-
{% trans '正在连线' %}{{ site.SITE_NAME.label }}
+
正在从{{ site.SITE_NAME.label }}获取
diff --git a/catalog/templates/search_results.html b/catalog/templates/search_results.html index 72a86534..bed3b7d0 100644 --- a/catalog/templates/search_results.html +++ b/catalog/templates/search_results.html @@ -20,31 +20,70 @@ {% include '_header.html' %}
-
-
+
+
{% if request.GET.q %} -
“{{ request.GET.q }}” {% trans '的搜索结果' %}
+
+
“{{ request.GET.q }}” {% trans '的搜索结果' %}
+
+ {% if request.GET.c != 'book' %} + 书籍 + {% else %} + 书籍 + {% endif %} + | + {% if request.GET.c != 'movietv' %} + 影视 + {% else %} + 影视 + {% endif %} + | + {% if request.GET.c != 'podcast' %} + 播客 + {% else %} + 播客 + {% endif %} + | + {% if request.GET.c != 'music' %} + 音乐 + {% else %} + 音乐 + {% endif %} + | + {% if request.GET.c != 'game' %} + 游戏 + {% else %} + 游戏 + {% endif %} + | + {% if request.GET.c and request.GET.c != 'all' %} + 全部 + {% else %} + 全部 + {% endif %} +
+
{% endif %} {% if request.GET.tag %}
{% trans '含有标签' %} “{{ request.GET.tag }}” {% trans '的结果' %}
{% endif %} -
    +
    {% for item in items %} {% with "list_item_"|add:item.class_name|add:".html" as template %} {% include template with show_tags=1 %} {% endwith %} {% empty %} -
  • {% trans '无站内条目匹配' %}
  • +

    {% trans '无站内条目匹配' %}

    {% endfor %} {% if request.GET.q and user.is_authenticated %} -
  • - {% trans '正在实时搜索站外条目' %} +

    -

  • + {% trans '正在实时搜索站外条目' %} +

    {% endif %} -
+