Search

Full-text search over your content, powered by SQLite FTS5 — no external search service. Point it at a directory and query it.

Basil-only. @SEARCH requires the Basil server environment.

Quick Start

let search = @SEARCH({
    watch: @./docs,
    path: "search.db"
})

let results = search.query(@params.q, {limit: 10})

<ul>
    for (result in results.items) {
        <li>
            <a href={"/" + result.path}>result.title</a>
            <p>result.snippet</p>
        </li>
    }
</ul>

On first query, Basil scans the watched folder, parses YAML frontmatter (title, tags, date), extracts headings for ranking, and builds the index. Subsequent queries hit the index.

@SEARCH(options)

Key Type Description
path string SQLite index file (":memory:" for tests)
watch path or array Folder(s) to index automatically

Indexes Markdown and HTML out of the box, plus text-based PDF and DOCX files (50 MB per-file limit).

search.query(text, options?)

Key Type Default Description
limit int 10 Maximum results
offset int 0 Pagination offset

Returns {items, total} where each item has path, title, and a highlighted snippet.

When to Use It

Good for documentation sites, blogs, wikis, and apps up to roughly 100k documents — anything where "just works, zero config" beats search-cluster features. If you need typo tolerance, multi-language stemming, or millions of documents, reach for Meilisearch or Elasticsearch instead.

See Also