The blog ships with Orama as its default search engine. Orama is an in-process TypeScript search library: typo tolerance, BM25 ranking, filters, facets, and (optionally) vector search work without another service.
Defaults and fallback
- Orama is the default. It builds its index lazily from published posts and updates it after admin saves.
- Database is the no-embedded-index fallback. It searches the repository directly and needs no service.
- The index is per-process. A multi-instance deployment should choose an external engine or rebuild each process against the same content.
Selecting an engine
createBlogSearchEngine is the engine-neutral factory:
import { createBlogSearchEngine } from '@jsails/blog';
const search = createBlogSearchEngine({
driver: process.env.SEARCH_DRIVER ?? 'orama',
repository: blogRepository,
url: process.env.SEARCH_URL,
apiKey: process.env.SEARCH_API_KEY,
index: process.env.SEARCH_INDEX,
timeoutMs: 5000, // optional per-request bound for the external drivers
});
Pass the same instance to blogPlugin({ search }) and
blogAdmin({ search }) (from @jsails/blog/admin). Supported drivers:
orama— default embedded enginedatabase— repository search, no servicemeilisearchtypesenseopensearch
The external drivers configure their own index on first use: Meilisearch gets
its searchable/filterable/sortable attributes, Typesense its collection schema,
and OpenSearch an explicit mapping (status keyword, publishedAt date). Each
request is bounded by timeoutMs (default 5000 ms), so a stalled engine fails
fast instead of holding a public search or an admin save open; reindex uses
each engine's bulk endpoint in batches of 100. When the engine is unreachable,
GET /blog/search answers 503 with the search form rather than a server
error. The query is truncated to 200 characters
(BLOG_SEARCH_MAX_QUERY_LENGTH).
Jamal services
External engines are opt-in services in jamal.config.ts, like Laravel Sail:
services: {
db: { type: 'mariadb' },
valkey: { type: 'valkey' },
search: { type: 'meilisearch' },
},
local: {
ports: { db: 3306, valkey: 6379, search: 7700 },
},
Jamal also supports typesense and opensearch. Add only the service you
select. Orama and the database driver need no search service.
SEARCH_DRIVER=meilisearch with SEARCH_URL=http://127.0.0.1:7700 is the
first external setup. Typesense requires an API key; OpenSearch is intended for
enterprise/hosted deployments.