Meilisearch
zero exposes Meilisearch through the unified ctx.Search handle (the same handle used for Solr). Meilisearch is a fast, HTTP-based search engine; zero talks to it with a small pure-Zig client.
Quickstart
Spin up a local Meilisearch with a master key:
bash
podman pull docker.io/getmeili/meilisearch:v1.12
podman run -d \
--name meilisearch \
-p 7700:7700 \
-v meili-data:/meili_data \
-e MEILI_MASTER_KEY='a_secure_master_key_at_least_32_chars_long' \
docker.io/getmeili/meilisearch:v1.12Configuration
bash
MEILI_HOST=http://localhost:7700
MEILI_INDEX=movies
MEILI_API_KEY= # optional; sent as Authorization: BearerAPI
ctx.Search is unchanged: index, fetch, delete, and query documents regardless of backend:
zig
pub fn addDoc(ctx: *Context) !void {
try ctx.Search.?.index(ctx, "movies",
"[{\"id\":1,\"title\":\"Inception\"}]");
}
pub fn search(ctx: *Context) !void {
const res = try ctx.Search.?.query(ctx, "movies", "inception");
defer ctx.allocator.free(res);
try ctx.json(res);
}index(ctx, collection, doc_json): upsert a JSON doc.query(ctx, collection, q): search.get(ctx, collection, id): fetch a doc by id (nullon 404).delete(ctx, collection, id): delete a doc by id.lastError(): surfaces the upstream status.
ctx.Search is optional. Guard with if (ctx.Search) |s| { ... }. Free returned slices with ctx.allocator.
Caveats
- The search call sends only
{"q":"<term>"}. Filters, facets, pagination, andattributesToRetrieveare not supported yet. - No circuit breaker is wired yet.
See the runnable zero-search example and the implementation in src/datasource/search/meili.zig.