matrix-org / matrix-org/matrix-rust-sdk
Meta: Full text search support
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 500
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 106
Description
Introduction
As users post messages and the room history grows over time, manually scrolling to find a past conversation becomes inefficient and frustrating.
In today's world, users expect to be able to find past conversations easily and quickly. Adding full text search would greatly improve usability by allowing users to search across messages with filters like sender, date ranges, and on a per-room basis.
Element Desktop has been supporting full text search for quite a while now. It utilizes Seshat which uses a SQLite database in combination with a full-text search index (backed by Tantivy) to provide a simple API to feed events into the database/index and search and retrieve the events.
Plan
The Rust SDK already contains a persistent store for events we encounter. This fact and Seshat itself being stuck on a quite old version of the used full-text search library makes direct adoption of Seshat unfeasible.
Nevertheless, some parts of Seshat will be useful, for example Seshat contains a storage backend for Tantivy which encrypts the index.
This issue lies down the tasks that would be necessary to bring full-text search support into the Rust SDK.
Because we can't adopt Seshat directly, we will begin with the creation of a new crate in this very repository. After that we can add a simple API to index events and search the index.
Once a functioning API exists, we can experiment with the search functionality using benchmarks, small test clients and finally multiverse.
MVP tasks for internship
The following list of tasks lays out the rough plan:
- Create a new create called matrix-sdk-search.
- Implement a basic API to add events to and index using. Tantivy
- Add support to search for events.
- Extend multiverse so we can test out the search API and functionality.
- Utilize the matrix-sdk-search crate in the
EventCache, every time theEventCacheinserts an event, index the event. - Add support for edits and redactions
- Test out and benchmark if a per-room index is better than a global index.
- Pagination
- Implement room spidering so we index the whole room history.
- Fix search on first viewing
- Support encrypted index.
- Update README with information and code examples.
- Record a demo of search in Multiverse.
Nice to have
- Global search.
- Background spidering
- Try bulk operations to reduce index commits.
- Make index writes/commits non-blocking.
- Add
SearchQueryBuilder - Add support for a per-room language setting, the setting should be part of the room state. MSC4334 has an unstable ruma impl
Implementation notes
- Redaction must remove the redacted event from the index.
- Ignoring a user must remove all their sent events from the index.
- Banning a user could preemptively remove all their sent events from the index.
- Leaving a room should remove the on-disk index, if there was one.
Notes for the future
- Indexes are stored in
<index path>/<room id>/but given that different clients could exist this would have to be changed to<index path>/<user id>/<room id>/so that each<index path>/<client id>can be encrypted independantly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.