From 313ea261f7d07ea68ac3c753fa6930d139b28c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bournhonesque?= Date: Fri, 22 Sep 2023 23:39:31 +0200 Subject: [PATCH] fix: fix sorting --- app/api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api.py b/app/api.py index 3abb6662..7350fed7 100644 --- a/app/api.py +++ b/app/api.py @@ -119,6 +119,7 @@ def search( query = build_search_query( q=q, langs=langs, size=page_size, page=page, config=CONFIG, sort_by=sort_by ) + logger.debug("Elasticsearch query: %s", query.to_dict()) results = query.execute() projection = set(fields.split(",")) if fields else None @@ -144,11 +145,10 @@ def html_search( langs: str = "fr,en", sort_by: str | None = None, ): - if q: - results = search(q, langs, page_size, page, sort_by) - else: + if not q: return templates.TemplateResponse("search.html", {"request": request}) + results = search(q=q, langs=langs, page_size=page_size, page=page, sort_by=sort_by) page_count = results["page_count"] pagination = [ {"name": p, "selected": p == page, "page_id": p}