Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSC3666: Bundled aggregations for server side search #3666

Merged
merged 6 commits into from
Apr 10, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions proposals/3666-bundled-aggregations-for-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# MSC3666: Bundled aggregations for server side search
turt2live marked this conversation as resolved.
Show resolved Hide resolved

[MSC2675](https://github.com/matrix-org/matrix-doc/pull/2675) defines a way for
homeservers to include events related to a requested event via "bundled aggregations".
These bundled aggregations help a client render a requested event without needing
to fetch additional information from the server.

As part of MSC2675 the following APIs should include bundled aggregations:

* `GET /rooms/{roomId}/messages`
* `GET /rooms/{roomId}/context/{eventId}`
* `GET /rooms/{roomId}/event/{eventId}`
* `GET /sync`, only for room sections in the response where limited field is true;
this amounts to all rooms in the response if the since request parameter was
not passed, also known as an initial sync.
* `GET /rooms{roomId}/relations/{eventId}`
clokep marked this conversation as resolved.
Show resolved Hide resolved

A noticeable missing API from here is the server side search feature (`POST /search`)
where it is common for a client to not have the full timeline of a room when
receiving results. This would benefit from having the bundled aggregations.


## Proposal

The server side search API (`POST /search`) for the `room_events` category will
clokep marked this conversation as resolved.
Show resolved Hide resolved
include bundled aggregations for any matching events returned to the client.
Per MSC2675 the `unsigned` field of the results would include `m.relations` where
clokep marked this conversation as resolved.
Show resolved Hide resolved
appropriate. This applies to any events themselves, as well as contextual events
returned, these appear as the following fields:
clokep marked this conversation as resolved.
Show resolved Hide resolved

* The event itself: `results["search_categories"]["room_events"]["results"]["result"]`
* Each contextual event in:
* `results["search_categories"]["room_events"]["results"]["context"]["events_before"]`
* `results["search_categories"]["room_events"]["results"]["context"]["events_after"]`


## Potential issues

The `/search` API is already fairly complicated and can be slow for large rooms.
Returning more data from it could cause performance issues.


## Alternatives

The status quo is that a client can call `/rooms{roomId}/relations/{eventId}` for
each event in the search results in order to fully render each event. This is
expensive, slow, and bandwidth heavy since clients generally need the aggregated
relations, not each related event.

Older versions of MSC2675 included an `/rooms{roomId}/aggregations/{eventId}` API
to fetch the bundled aggregations for an event directly. This would save on bandwidth
and simplify the work that clients need to achieve, but would still need result
clokep marked this conversation as resolved.
Show resolved Hide resolved
in needless roundtrips as it would have to be called per event.


## Security considerations

None.


## Unstable prefix

N/A
richvdh marked this conversation as resolved.
Show resolved Hide resolved


## Dependencies

This MSC builds on [MSC2674](https://github.com/matrix-org/matrix-doc/pull/2674)
and [MSC2675](https://github.com/matrix-org/matrix-doc/pull/2675), which have
been accepted, but are not yet in a released version of the spec at the time of
writing.