From 1f5afd75c6e7d0a2ff336b4b780b54df42a3d56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 13 Jun 2019 12:32:52 +0200 Subject: [PATCH] client: Allow per room search. This is not ideal. We only support a single room or all rooms, which is good enough for now since riot does that. The tantivy boolean query logic isn't ideal and didn't work out with multiple rooms in the query. --- pantalaimon/client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pantalaimon/client.py b/pantalaimon/client.py index 9e34e24..a45c77e 100644 --- a/pantalaimon/client.py +++ b/pantalaimon/client.py @@ -723,6 +723,10 @@ class PanClient(AsyncClient): if limit <= 0: raise InvalidLimit(f"The limit must be strictly greater than 0.") + rooms = search_filter.get("rooms", []) + + room_id = rooms[0] if len(rooms) == 1 else None + order_by = search_terms.get("order_by") if order_by not in ["rank", "recent"]: @@ -743,8 +747,8 @@ class PanClient(AsyncClient): include_profile = event_context.get("include_profile", False) searcher = self.index.searcher() - search_func = partial(searcher.search, term, max_results=limit, - order_by_date=order_by_date) + search_func = partial(searcher.search, term, room=room_id, + max_results=limit, order_by_date=order_by_date) result = await loop.run_in_executor(None, search_func)