# FTS5 Full-Text Search SUMMARY: How Synapse uses SQLite FTS5 for sub-millisecond full-text memory search. FTS5 Full-Text Search Synapse uses FTS5 (Full-Text Search 5) for fast, flexible memory search. This page explains how it works and how to use it effectively. What is FTS5? FTS5 is a SQLite extension (also available in PostgreSQL via extensions) that provides full-text search capabilities. It: - Indexes text content for fast keyword search - Supports boolean operators (AND, OR, NOT) - Supports phrase matching with quotes - Supports prefix matching with - Ranks results by relevance Synapse uses FTS5 to index all memory content, enabling sub-millisecond search across thousands of memories. How Synapse Uses FTS5 When you : 1. Memory content is stored in the table 2. Content is also inserted into the FTS5 virtual table 3. FTS5 automatically tokenizes and indexes the content When you : 1. Synapse parses the query using FTS5 syntax 2. Executes a against the FTS5 index 3. Filters by (tenant isolation) 4. Returns ranked results Query Syntax Simple keyword search [CODE BLOCK] Returns memories containing "docker". Multiple keywords (implicit AND) [CODE BLOCK] Returns memories containing BOTH "docker" AND "swarm". Phrase matching [CODE BLOCK] Returns memories containing the exact phrase "docker swarm". Prefix matching [CODE BLOCK] Returns memories containing words starting with "docker" (e.g. "dockers", "dockerfile", "dockerize"). Boolean OR [CODE BLOCK] Returns memories containing "docker" OR "kubernetes". Boolean NOT [CODE BLOCK] Returns memories containing "docker" but NOT "swarm". Grouping [CODE BLOCK] Returns memories containing "docker" or "kubernetes", but not "test". Practical Examples Find memories about a project [CODE BLOCK] Find exact phrase [CODE BLOCK] Exclude test memories [CODE BLOCK] Find by technology [CODE BLOCK] Ranking FTS5 ranks results by relevance using BM25 algorithm. Factors: - Term frequency (how often the term appears) - Inverse document frequency (rarer terms rank higher) - Document length (shorter docs with the term rank higher) - Column weight (title > content) Results are returned in rank order (most relevant first). Performance | Operation | Latency | |-----------|---------| | Search 100 memories | < 5ms | | Search 1,000 memories | < 10ms | | Search 10,000 memories | < 25ms | | Search 100,000 memories | < 100ms | FTS5 is highly optimized for read-heavy workloads. Limitations Stemming FTS5 doesn't do stemming by default. "running" and "run" are different terms. Workaround: Use prefix matching: Typo tolerance FTS5 doesn't support fuzzy matching. A typo will return no results. Workaround: Use semantic search () for conceptual matching. Stop words Common words (the, a, an, is) are indexed but may not be useful for search. FTS5 handles this automatically. FTS5 vs Semantic Search | Aspect | FTS5 | Semantic Search | |--------|------|-----------------| | Speed | Sub-millisecond | 50-100ms | | Matching | Exact keywords | Conceptual | | Typo tolerance | None | Some | | Stemming | None | Implicit | | Requires embeddings | No | Yes | | Best for | Specific terms | Concepts | Use FTS5 when you know the keywords. Use semantic search when you want "memories about X" where X is described differently. Best Practices > [!TIP] > - Use specific terms — "docker swarm" beats "container orchestration" > - Quote phrases — ensures phrase match > - Use prefix for variations — catches "deploy", "deployment", "deploying" > - Exclude noise — filters out test memories > - Combine with tags — narrows results Next Steps - Semantic Search - Memory API - Memory Best Practices