Search / Search
Search
The Search engine finds documents by their words in any language, forgiving
typos, by the vectors your embedding model makes, or by both. An index keeps
its own documents in search.db, or follows a table of an application's
database and changes in the same commit as its rows. Searches are exact by
default.
const articles = store.index<Article>('articles', { fields: { title: 2, body: 1 }, filters: ['authorId'] })
await articles.set('a-17', { title: 'Как испечь хлеб', body: '…', authorId: 42 })
const { hits, corrected } = await articles.search({ text: 'хлеба', where: { authorId: 42 } })articles = store.index("articles", Article, fields={"title": 2, "body": 1}, filters=["author_id"])
await articles.set("a-17", Article(title="Как испечь хлеб", body="…", author_id=42))
result = await articles.search(text="хлеба", where={"author_id": 42})What it guarantees
- A search by words answers what scoring every document would, by BM25, never an estimate (contract SRCH-01).
- A search by a vector answers the exact best by cosine, unless the index
asked for
recall(contract SRCH-02). - A filter keeps to the documents it passes before ranking (contract SRCH-03).
- A document set is found by the next search; a deleted one never again (contract SRCH-04).
- A table's index changes in the commit that changes the row (contract SRCH-07).
- A misspelt word is read as its nearest, and
correctedsays so; a word that matches is never changed (contract SRCH-09).
In these guides
| Page | Covers |
|---|---|
| Fields and weights | which text is read, and how much each field counts |
| Typos | the nearest word, corrected, typoTolerance |
| Filters | where, lists, ranges, search.or |
| Vectors | dimensions, exact search, recall and clusters |
| Words and vectors together | vectorWeight, rerank |
| A table's index | db.searchIndex, triggers, ready |
| Rebuilds | changing fields and filters while the index answers |
New to Search? Finding old messages in the Handbook indexes a chat's messages, and How search finds explains the index.
Reference
Bun and Node · Python · Go · Rust