Meilisearch
Set up Meilisearch to enable conversation search in LibreChat
Meilisearch is an open-source search engine that powers LibreChat's conversation search, adding full-text search, typo tolerance, and instant results across past conversations. For a feature overview, see Search in LibreChat.
How it connects
LibreChat talks to Meilisearch over HTTP using a few environment variables. The Docker setup ships Meilisearch as a service for you. A source install points LibreChat at a Meilisearch process you run yourself.
Configure Meilisearch
The default docker-compose.yml already includes a meilisearch service, so you only need to enable search and set a master key in your .env file.
Generate a master key. Use any sufficiently long, random string (16 bytes or more). For example:
Add the search variables to .env. The Compose file sets MEILI_HOST to the internal service address for the api container, so you don't set the host here. Keep the master key identical to the one the meilisearch service uses.
Pass the master key to the Meilisearch service. The bundled meilisearch service does not read .env, so add it through docker-compose.override.yml. This keeps both LibreChat and Meilisearch using the same key.
See Docker Override for how override files are merged.
Start the stack. Compose merges the override automatically and starts Meilisearch alongside LibreChat.
Keep the port internal
Containers reach Meilisearch over the internal Docker network, so there is no need to publish port 7700 to the host. Exposing it publicly can leave your search data vulnerable.
Once configured, LibreChat indexes conversations and messages into Meilisearch, and the search bar returns full-text results with typo tolerance.
Environment Variables
| Variable | Description |
|---|---|
SEARCH | Enables the conversation search feature. Set to true. |
MEILI_HOST | URL where LibreChat reaches Meilisearch. In Docker this is http://meilisearch:7700 (set by Compose); from source it is typically http://localhost:7700. |
MEILI_MASTER_KEY | Shared secret used to authenticate with Meilisearch. Must match the key Meilisearch starts with. |
MEILI_NO_ANALYTICS | Disables Meilisearch's anonymous telemetry. Set to true. |
MEILI_NO_SYNC | See multi-node setups. |
Disable Sync in a Multi-node Setup
If you run LibreChat as a node cluster or multi-node deployment, set MEILI_NO_SYNC to true so only one instance handles indexing. This prevents redundant syncing of database documents across instances and the unnecessary resource use that comes with it.
Reset Synchronization
If Meilisearch data is deleted or corrupted, or LibreChat treats everything as synced when it isn't (for example after upgrading Meilisearch or deleting its data files), use the reset script to force a full re-sync. It resets the synchronization flags in MongoDB, which triggers LibreChat to re-index all conversations and messages on the next startup or sync check.
Run the reset script. Use the command that matches your setup.
Restart LibreChat. Re-synchronization begins once the app restarts.
The script resets the _meiliIndex flag to false for all messages and conversations in MongoDB, then reports how many documents were reset and how many remain to be synced.
When to use it:
- After deleting Meilisearch data files
- When upgrading Meilisearch to a version that requires reindexing
- When LibreChat shows conversations as fully synced but Meilisearch is missing data
- After restoring a MongoDB backup without matching Meilisearch data
Advanced sync options. After resetting, control the sync behavior with these environment variables:
| Variable | Default | Description |
|---|---|---|
MEILI_SYNC_BATCH_SIZE | 100 | Number of documents synced per batch. |
MEILI_SYNC_DELAY_MS | 100 | Delay between sync batches, in milliseconds. |
MEILI_SYNC_THRESHOLD | 1000 | Minimum number of unsynced documents before a sync is triggered. |
How is this guide?