From af0f4fa052655f18d590e657f132961e0bc41d75 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 19 Jul 2024 08:33:42 -0400 Subject: [PATCH] fix search for real --- catalog/search/typesense.py | 1 + catalog/search/views.py | 2 +- journal/models/tag.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/catalog/search/typesense.py b/catalog/search/typesense.py index 95802018..a1252b86 100644 --- a/catalog/search/typesense.py +++ b/catalog/search/typesense.py @@ -29,6 +29,7 @@ "pub_house", "company", "publisher", + "host", "isbn", "imdb", "barcode", diff --git a/catalog/search/views.py b/catalog/search/views.py index 592fe2b0..23d16f65 100644 --- a/catalog/search/views.py +++ b/catalog/search/views.py @@ -114,7 +114,7 @@ def search(request): except Exception: categories = visible_categories(request) tag = request.GET.get("tag", default="").strip() - tag = Tag.deep_cleanup_title(tag) + tag = Tag.deep_cleanup_title(tag, default="") p = request.GET.get("page", default="1") p = int(p) if p.isdigit() else 1 if not (keywords or tag): diff --git a/journal/models/tag.py b/journal/models/tag.py index 42b18f41..f2b34e5a 100644 --- a/journal/models/tag.py +++ b/journal/models/tag.py @@ -59,9 +59,9 @@ def cleanup_title(title, replace=True): return "_" if not t and replace else t @staticmethod - def deep_cleanup_title(title): + def deep_cleanup_title(title, default="_"): """Remove all non-word characters, only for public index purpose""" - return re.sub(r"\W+", " ", title).rstrip().lstrip("# ").lower()[:100] or "_" + return re.sub(r"\W+", " ", title).rstrip().lstrip("# ").lower()[:100] or default def update( self, title: str, visibility: int | None = None, pinned: bool | None = None