Firebase Firestore with Algolia - Multiple Indexs

I’m using a database in Firebase’s new Firestore.

I’ve set up the database using Cloud Functions to pull in data to from Firebase to Algolia whenever there is a change in the database.

I’m using the sample code from Google’s Firebase samples…https://github.com/firebase/functions-samples/tree/master/fulltext-search-firestore.

I’m wondering how to update multiple databases, however.

For example - there are 3 indexes I would like to link up.

Airports
Locations
Users

These are 3 separate collections in Firestore. Each user has an array of ‘Liked Locations’ and a ‘Home Airport’ but other than this they all have their own data.

So how would this structure be best set up? In ONE function or separate functions to get all the indices updated on Algolia?

1 Like

I simply duplicated the

exports.onLocationCreated = functions.firestore.document(‘locations/{locationId}’).onCreate

function and it works.

However, this is only for when a document is created. I’m trying to listen to it during the entire CRUD process.

Hey @phil.manning11,

You can check out Firestore documentation for the Cloud Firestore Triggers.

Cheers!

1 Like

@phil.manning11 You need to implement onUpdate and onDelete too. Or just implement onWrite which handles the all three methods

1 Like