Search
Full-text search across chat titles and message content powered by SQLite FTS5.
Opengram includes full-text search powered by SQLite's FTS5 extension. Users can search across chat titles, message content, or both.
Search Scopes
There are three search scopes:
| Scope | What it searches |
|---|---|
titles | Chat titles only |
messages | Message content only |
all | Both titles and messages |
Using Search in the UI
Search is accessed through the search icon in the chat list header. Typing a query filters results in real time. Users can switch between scopes to narrow down results.
Search results show:
- Chat matches -- chats whose title matches the query
- Message matches -- individual messages that match, grouped by chat, with a snippet highlighting the matched text
Tapping a result navigates directly to that chat or to the specific message within the chat.
API
The search endpoint is available for agents and integrations:
GET /api/v1/search?q=hello&scope=titles&limit=20Parameters
| Parameter | Type | Default | Max | Description |
|---|---|---|---|---|
q | string | required | -- | The search query |
scope | string | titles | -- | One of titles, messages, or all |
limit | number | 50 | 100 | Maximum number of results per page |
cursor | string | -- | -- | Cursor for pagination (from previous response) |
See the full API details at Search API reference.
How Search Works
Opengram uses two different strategies depending on the scope:
- Title search (
titlesscope) uses SQLLIKEfor substring matching. A query likeprojmatches any chat whose title contains that substring (e.g. "My Project", "project-alpha"). - Message search (
messagesscope) uses SQLite FTS5 for full-text word matching. An FTS5 virtual table is maintained automatically via database triggers -- whenever messages are created, updated, or deleted, the index stays in sync.
When the scope is all, both strategies run and results are merged by timestamp.
No additional setup is required -- the FTS5 index and triggers are created automatically when Opengram starts.
Query behavior
User input is automatically processed before searching -- you don't need to use any special syntax.
| Input | What happens |
|---|---|
hello | Matches messages containing any word starting with hello (e.g. "hello", "helloworld") |
hello world | Matches messages containing both terms (implicit AND). The last term is prefix-matched. |
deploy prod | Matches messages with "deploy" AND any word starting with "prod" |
The last term always gets a prefix wildcard, which makes search work well for typeahead / search-as-you-type.
For title search, the query is matched as a plain substring anywhere in the title. For message search, each word is matched at word boundaries using FTS5.
Result snippets
Search results include a snippet field:
- Chat matches return the full chat title as the snippet.
- Message matches return a ~20-word excerpt around the matched terms, with matches wrapped in
<mark>HTML tags for highlighting.