~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/hatk

AT Protocol app framework

1
0
main
51 lines · 1.5 KB Raw History

title: Search description: Search API endpoints.

dev.hatk.searchRecords

Full-text search across a collection using SQLite FTS5 with BM25 ranking.

  • Type: Query (GET)
  • Auth: None

Parameters

NameTypeRequiredDefaultDescription
collectionstringYes—Collection NSID to search
qstringYes—Search query
limitintegerNo20Results per page (1–100)
cursorstringNo—Pagination cursor
fuzzybooleanNotrueEnable fuzzy matching

Example

curl "http://127.0.0.1:3000/xrpc/dev.hatk.searchRecords?collection=fm.teal.alpha.feed.play&q=radiohead"
import { callXrpc } from '$hatk/client'

const { items, cursor } = await callXrpc('dev.hatk.searchRecords', {
  collection: 'fm.teal.alpha.feed.play',
  q: 'radiohead',
})

Response

{
  "items": [ ... ],
  "cursor": "..."
}

How it works

Hatk 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.

Search uses BM25 ranking to order results by relevance. The fuzzy parameter (enabled by default) allows approximate matching for typos and partial terms.