Prerequisites
The official firestore-meilisearch extension automatically synchronizes documents from a Cloud Firestore collection to a Meilisearch index, enabling full-text search on your Firestore data.
Meilisearch Cloud is the easiest way to get a Meilisearch instance for use with Firebase.
Prerequisites
- A Firebase project on the Blaze (pay-as-you-go) plan
- Cloud Firestore set up in your Firebase project
- A running Meilisearch instance (Cloud or self-hosted)
- A Meilisearch API key with write permissions
Install the extension
You can install the extension using the Firebase Console or the Firebase CLI.
- Firebase Console
- Firebase CLI
Visit the Firebase Extensions Hub and click Install.Follow the prompts to select your Firebase project and configure the extension.
firebase ext:install meilisearch/firestore-meilisearch --project=YOUR_PROJECT_ID
Replace YOUR_PROJECT_ID with your Firebase project ID.
Configuration
During installation, you’ll configure the following parameters:
| Parameter | Description |
|---|---|
| Cloud Functions location | Region where the extension’s functions will be deployed |
| Collection path | The Firestore collection to sync (e.g., products, articles) |
| Fields to index | Comma-separated list of field names, or leave blank to index all fields |
| Meilisearch index name | The name of the Meilisearch index to sync data to |
| Meilisearch host | Your Meilisearch instance URL (must start with http:// or https://) |
| Meilisearch API key | An API key with permission to manage indexes |
How it works
Once installed, the extension deploys a Cloud Function called indexingWorker that:
- Listens for document creates, updates, and deletions in your specified collection
- Syncs changes to your Meilisearch index in real-time
- Maps Firestore document IDs to a
_firestore_idfield in Meilisearch
The extension only monitors the specified collection, not subcollections. Install additional instances to sync other collections.
Data format
Document IDs
Firestore document IDs are automatically mapped to a _firestore_id field in Meilisearch. Any field named _firestore_id in your source documents will be ignored.
Geolocation
For geo search functionality, name your GeoPoint field _geo in Firestore. Meilisearch will automatically recognize it for geo search queries.
// Firestore document with geo data
{
name: "Eiffel Tower",
_geo: new firebase.firestore.GeoPoint(48.8584, 2.2945)
}
Import existing documents
The extension only syncs documents created or modified after installation. To import existing documents, use the provided import script:
npx @meilisearch/firestore-meilisearch-scripts import
See the for detailed instructions.
Search your data
Once your data is synced, you can search it using any Meilisearch SDK or the REST API:
- JavaScript
- cURL
import { Meilisearch } from 'meilisearch'
const client = new Meilisearch({
host: process.env.MEILISEARCH_URL,
apiKey: process.env.MEILISEARCH_KEY
})
const results = await client.index('products').search('phone')
console.log(results.hits)
curl "${MEILISEARCH_URL}/indexes/products/search" \
-H "Authorization: Bearer ${MEILISEARCH_KEY}" \
-H "Content-Type: application/json" \
-d '{"q": "phone"}'
