Skip to content

Enable the global search

The global workspace search is backed by Meilisearch. It is off by default (SEARCH_ENABLED=false): no indexing task is dispatched, /api/search answers 503 and the client hides its entry point.

This page is for people who run a madbot instance. For a local development checkout, see Start Meilisearch.

Prefer a dedicated host when possible: memory usage scales with index size and (re)indexing is CPU-intensive. Install Meilisearch with the official install script and run it under systemd or Supervisor, with --env production. Bind it to an address only the API can reach: 127.0.0.1:7700 when it shares the API host, otherwise a private address closed by a firewall.

Choose a master key of at least 16 bytes. Keep it for administrators only: it grants every right on the Meilisearch instance, including creating API keys. Production mode requires that key and disables Meilisearch’s preview web UI.

Do not put the master key in the madbot configuration. Create a key limited to the workspace_search index and to what the API uses:

Terminal window
curl -X POST "$MEILISEARCH_HOST/keys" \
-H "Authorization: Bearer <the master key>" \
-H "Content-Type: application/json" \
--data '{
"description": "madbot API",
"actions": ["search", "documents.add", "documents.get", "documents.delete",
"indexes.create", "indexes.get", "indexes.update",
"settings.get", "settings.update", "tasks.get"],
"indexes": ["workspace_search"],
"expiresAt": null
}'

Put the key of the response in the madbot environment as MEILISEARCH_API_KEY.

In the API environment (for example /etc/madbot/madbot.env):

Terminal window
SEARCH_ENABLED=true
MEILISEARCH_HOST=http://<meilisearch address>:7700
MEILISEARCH_API_KEY=<the restricted key>

SEARCH_ENABLED=true must be present: the flag defaults to off, and without it the search simply disappears from the interface. Restart the API and the Celery workers so they pick up the settings.

Enabling the search also registers a Meilisearch check on /health-check as a non-critical service: an unreachable Meilisearch shows as degraded there without failing the endpoint.

After enabling the search, and after upgrades that change filterable attributes, rebuild the index from the database:

Terminal window
madbot rebuild_search_index

See rebuild_search_index. The index is never emptied first, so the search keeps answering while the command runs. Day-to-day updates then go through Celery: keep a worker running.