Opengram

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:

ScopeWhat it searches
titlesChat titles only
messagesMessage content only
allBoth 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=20

Parameters

ParameterTypeDefaultMaxDescription
qstringrequired--The search query
scopestringtitles--One of titles, messages, or all
limitnumber50100Maximum number of results per page
cursorstring----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 (titles scope) uses SQL LIKE for substring matching. A query like proj matches any chat whose title contains that substring (e.g. "My Project", "project-alpha").
  • Message search (messages scope) 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.

InputWhat happens
helloMatches messages containing any word starting with hello (e.g. "hello", "helloworld")
hello worldMatches messages containing both terms (implicit AND). The last term is prefix-matched.
deploy prodMatches 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.

On this page