Text search with Algolia
Make sure that npm and Node are installed
install Firebase CLI with npm:
npm install -g firebase-tools
install algoliasearch for text search lib:
npm install algoliasearch --save
- Initialize Firebase SDK for Cloud Function:
- Run firebase login, loging to your firebase account
- Run firebase init function, with this command, you will be prompted to create a new project or use existing project, npm dependencies management will be offered, and what language options you can choose
- Initialize Admin SDK with admin.initializeApp()
- Store environment data into firebase for algolia run
firebase functions:config:set algolia.key="THE API KEY" algolia.name="THE CLIENT name"
After all setup is done, time to add some lines of code. in order to use Firebase SDK modules, import the module into index.ts
After all setup is done, import algoliasearch into index.ts. To use envorinment variables in firebase, use e.g function.config().algolia.key. Use algolia saveObject() as a promise to terminate the cloud function