duckdb-searchlisted
Install: claude install-skill srimon12/duckdb-2-skills
# Search indexes
Before writing SQL, choose among four search paths. Full-text ranks by keywords, layered full-text adds prefix and typo matching, HNSW ranks by vector distance, and hybrid fusion combines keywords and vectors. For spatial or as-of proximity, use `NEAREST` joins in `duckdb-sql` instead of an index. To install or load `fts` or `vss` offline, follow `duckdb-extensions`.
## Pick the path
| Question | Path | First command |
| --- | --- | --- |
| Which rows contain these words, ranked by relevance? | BM25 | `PRAGMA create_fts_index(...)` |
| Which rows contain this prefix, typo, or phrase? | Layered BM25 | `layered_search = 1` |
| Which vectors are closest to this embedding? | HNSW | `CREATE INDEX ... USING HNSW` |
| Combine keywords and embeddings | Two indexes | Fuse the ranks in SQL |
For one-off queries, small tables, or narrow pre-filters, a sequential scan is usually faster than an index.
## Contract
For FTS:
```text
Inputs: one base table, one NOT NULL unique id, one or more text columns
Outputs: ranked ids and scores
Invariant: static index is a snapshot; incremental covers INSERT and DELETE, not UPDATE
Proof: inserted term is found, deleted term is gone, updated term is repaired
```
For HNSW:
```text
Inputs: one table, one FLOAT[N] column, non-null finite vectors
Outputs: top-k ids by one distance function
Invariant: index metric matches query function; query vector is a literal FLOAT[N]
Proof: EXPLAIN shows HNSW_