A Firebase extension to sync data from your Firestore collection to Typesense, to be able to do full-text fuzzy search on your Firestore data, with typo tolerance, faceting, filtering, sorting, curation, synonyms, geosearch and more.
This extension listens to your specified Firestore collection and syncs Firestore documents to Typesense on creation, updates and deletes. It also provides a function to help you backfill data.
What is Typesense?
If you're new to Typesense, it is an open source search engine that is simple to use, run and scale, with clean APIs and documentation. Think of it as an open source alternative to Algolia and an easier-to-use, batteries-included alternative to ElasticSearch. Get a quick overview from this guide.
Before installing this extension, make sure that you have:
- Set up a Cloud Firestore database in your Firebase project.
- Set up a Typesense cluster (on Typesense Cloud or Self-Hosted).
- Set up a Typesense Collection either through the Typesense Cloud dashboard or through the API.
You can install this extension either through the Firebase Web console or through the Firebase CLI.
firebase ext:install typesense/firestore-typesense-search@0.2.7 --project=[your-project-id]
Learn more about installing extensions in the Firebase Extensions documentation:
You can install this extension multiple times in your Firebase project by clicking on the installation link above multiple times, and use a different Firestore collection path in each installation instance. Here is a screenshot of how this looks.
This extension only syncs data that was created or changed in Firestore, after it was installed. In order to backfill data that already exists in your Firestore collection to your Typesense Collection:
- Create a new Firestore collection called
typesense_sync
through the Firestore UI. - Create a new document with the ID
backfill
and contents of{trigger: true}
This will trigger the backfill background Cloud function, which will read data from your Firestore collection and create equivalent documents in your Typesense collection.
To install an extension, your project must be on the Blaze (pay as you go) plan.
- You will be charged a small amount (typically around $0.01/month) for the Firebase resources required by this extension (even if it is not used).
- This extension uses other Firebase and Google Cloud Platform services, which have associated charges if you exceed the service’s free tier:
- Cloud Firestore
- Cloud Functions (Node.js 14+ runtime. See FAQs)
- Usage of this extension also requires you to have a running Typesense cluster either on Typesense Cloud or some self-hosted server. You are responsible for any associated costs with these services.
When you install this extension, you'll be able to configure the following parameters:
Parameter | Description |
---|---|
Firestore Collection Path | The Firestore collection that needs to be indexed into Typesense. |
Firestore Collection Fields | A comma separated list of fields that need to be indexed from each Firestore document. Leave blank to index all fields. |
Typesense Hosts | A comma-separated list of Typesense Hosts. For single node clusters, a single hostname is sufficient. For multi-node Highly Available or SDN Clusters, please be sure to mention all hostnames. |
Typesense API Key | An Typesense API key with admin permissions. Click on "Generate API Key" in cluster dashboard in Typesense Cloud. |
Typesense Collection Name | Typesense collection name to index data into. |
Cloud Functions location | Where do you want to deploy the functions created for this extension? You usually want a location close to your database. For help selecting a location, refer to the location selection guide. |
-
indexToTypesenseOnFirestoreWrite: A function that indexes data into Typesense when it's triggered by Firestore changes.
-
backfillToTypesenseFromFirestore: A function that backfills data from a Firestore collection into Typesense, triggered when a Firestore document with the path
typesense_sync/trigger
has the contents ofbackfill: true
.
This extension will operate with the following project IAM roles:
- datastore.user (Reason: Required to backfill data from your Firestore collection into Typesense)
npm run emulator
npm run typesenseServer
- Emulator UI will be accessible at http://localhost:4000.
- Local Typesense server will be accessible at http://localhost:8108
Add records in the Firestore UI and they should be created in Typesense.
npm run test
The Firebase CLI provides the following convenience command to auto-generate a README file containing content pulled from extension.yaml file and PREINSTALL.md file:
firebase ext:info ./ --markdown > README.md
- Update version number in extension.yaml
- Add entry to CHANGELOG.md
-
firebase ext:dev:publish typesense/firestore-typesense-search
- Create release in Github
Please open a Github issue or join our Slack community.