AppView in a box as a Vite plugin thing
hatk.dev
1---
2title: Search
3description: Search API endpoints.
4---
5
6## `dev.hatk.searchRecords`
7
8Full-text search across a collection using SQLite FTS5 with BM25 ranking.
9
10- **Type:** Query (GET)
11- **Auth:** None
12
13### Parameters
14
15| Name | Type | Required | Default | Description |
16| ------------ | ------- | -------- | ------- | ------------------------- |
17| `collection` | string | Yes | — | Collection NSID to search |
18| `q` | string | Yes | — | Search query |
19| `limit` | integer | No | `20` | Results per page (1–100) |
20| `cursor` | string | No | — | Pagination cursor |
21| `fuzzy` | boolean | No | `true` | Enable fuzzy matching |
22
23### Example
24
25```bash
26curl "http://127.0.0.1:3000/xrpc/dev.hatk.searchRecords?collection=fm.teal.alpha.feed.play&q=radiohead"
27```
28
29```typescript
30import { callXrpc } from "$hatk/client";
31
32const { items, cursor } = await callXrpc("dev.hatk.searchRecords", {
33 collection: "fm.teal.alpha.feed.play",
34 q: "radiohead",
35});
36```
37
38### Response
39
40```json
41{
42 "items": [ ... ],
43 "cursor": "..."
44}
45```
46
47### How it works
48
49Hatk builds a SQLite FTS5 full-text search index for each collection. String fields in your record lexicon definitions are automatically included in the index, which uses incremental updates so new records become searchable immediately.
50
51Search uses BM25 ranking to order results by relevance. The `fuzzy` parameter (enabled by default) allows approximate matching for typos and partial terms.