Search
Full-text search across all sessions with role filters, tool filters, and snippet highlighting.
"Searching is half of finding." — Senegalese proverb
Pi Session Manager provides powerful full-text search across all your sessions, powered by a dual-engine architecture combining SQLite FTS5 and Tantivy.
Search Engines
SQLite FTS5
The primary search engine. All session content is indexed into an FTS5 virtual table (message_fts) inside the SQLite database (~/.pi/agent/sessions/sessions.db). This provides:
- Fast prefix and phrase matching
- BM25 ranking (via
bm25()function) - Low memory footprint
- Auto-sync via
content='message_entries'(no manual triggers needed)
FTS5 can be toggled via the enable_fts5 setting in the configuration file.
Tantivy
A Rust-native full-text search library (similar to Lucene) used as a secondary index in data/search/tantivy.rs. Tantivy provides:
- More sophisticated tokenization (unicode61)
- Better relevance scoring for complex queries
- Concurrent indexing via
data/search/index.rs
Both engines are accessible through the unified search client (data/search/client.rs).
Session ID Matching
In addition to FTS, the search system supports exact and prefix matching on session IDs:
- Exact match: score 1,000,000
- Prefix match (≥3 chars): score 999,000
- Session ID results are always ranked above content matches
Content Search
Message-Level FTS5
Each message in a session is indexed individually in message_entries:
entry_id— unique message identifiersession_path— path to parent sessionrole— user or assistantsource_type— user, assistant, or thinkingcontent— message text
Search results are deduplicated per (session_path, entry_id) and limited to 3 hits per session.
CJK Support
For Chinese/Japanese/Korean text, FTS5 unicode61 tokenization is unreliable. The search falls back to LIKE substring matching when CJK characters are detected in the query.
Filters
Role Filter
Narrow results to specific message roles:
| Role | Description |
|---|---|
| All | Search across all messages |
| User | Only user messages |
| Assistant | Only AI responses |
Sort Order
Results can be sorted by:
| Sort | Description |
|---|---|
| Relevance (default) | Ranked by FTS5 BM25 score |
| Newest | Most recent messages first |
| Oldest | Oldest messages first |
Snippet Highlighting
Search results display content with matching text context. Click a result to jump directly to the matching message in the Session Viewer.
When a match is inside a toolResult entry, the viewer automatically resolves it to the parent assistant message containing the matching tool call, then scrolls to the correct position.
Plugin System
The search system uses a plugin architecture with three built-in plugins:
| Plugin | Searches |
|---|---|
| Session Plugin | Session names and metadata |
| Message Plugin | Message content (user, assistant, tool) |
| Project Plugin | Project directories and paths |
Plugins are registered in src/plugins/ and can be extended to add custom search sources.
Command Palette
Press Cmd/Ctrl + K to open the command palette — a cmdk-based interface that combines search with quick actions:
- Search sessions by name or content
- Switch views (list, project, kanban)
- Open settings
- Toggle terminal
- Navigate to any session
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Cmd/Ctrl + K | Open command palette |
Cmd/Ctrl + F | Focus sidebar search |
Esc | Clear search / close palette |