mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2025-07-08 15:49:30 -04:00
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.
This commit is contained in:
parent
fe10f54ea9
commit
1f5afd75c6
1 changed files with 6 additions and 2 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue