Skip to content

Commit

Permalink
fix: fix langs field in /search
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Sep 22, 2023
1 parent 3540190 commit 9a61270
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ def search(
),
] = None,
langs: Annotated[
list[str] | None,
str | None,
Query(
description="""A list of languages we want to support during search. This
list should include the user expected language, and additional languages (such
description="""A comma-separated list of languages we want to support during search.
This list should include the user expected language, and additional languages (such
as english for example).
This is currently used for language-specific subfields to choose in which
Expand Down Expand Up @@ -105,7 +105,17 @@ def search(
status_code=400, detail="`sort_by` must be provided when `q` is missing"
)

langs = set(langs or ["en"])
langs = set(langs.split(",") if langs else ["en"])
logger.debug(
"Received search query: q='%s', langs='%s', page=%d, "
"page_size=%d, fields='%s', sort_by='%s'",
q,
langs,
page,
page_size,
fields,
sort_by,
)
query = build_search_query(
q=q, langs=langs, size=page_size, page=page, config=CONFIG, sort_by=sort_by
)
Expand Down Expand Up @@ -133,10 +143,8 @@ def html_search(
langs: str = "fr,en",
sort_by: str | None = None,
):
logger.info("query: %s", q)
if q:
results = search(q, langs, page_size, page, sort_by)
logger.info(results)
else:
return templates.TemplateResponse("search.html", {"request": request})

Expand Down

0 comments on commit 9a61270

Please sign in to comment.