Pull request Compare This branch is 6 commits ahead, 146 commits behind Node-8.
nicolasgarnier Upgrade all firebase-admin imports to 5.11.0
Change-Id: Ib3f6a5f57d3fdd0dbc2ee3d27efbd3cf00966257
Latest commit 849ab0b Mar 26, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
functions Upgrade all firebase-admin imports to 5.11.0 Apr 3, 2018
README.md adding link to pricing page. Oct 5, 2017


Full-text search via Algolia

This template shows how to enable full text search on firebase database elements by using an Algolia hosted search service.

Functions Code

See file functions/index.js for the code.

The dependencies are listed in functions/package.json.

Sample Database Structure

As an example we'll be using a simple blog structure:

            text: "This is my first blog entry..."
            last_index_timestamp: 1234567890
            text: "This is my second blog entry..."
            last_index_timestamp: 1234567891
                query: "first entry"
                query: "second entry"
                hits: [...
                hits: [...
        /last_query_timestamp: 1234567892

Whenever a new blog post is created or modified a Function sends the content to be indexed to the Algolia instance. To perform new searches clients add the search query to the realtime database under /search/queries/ which triggers a Firebase function which performs the search on the Algolia instance. The results are written under the /search/results/ tree.

Setting up the sample

Create an Algolia account at www.algolia.com.

Enable Billing on your Firebase project by switching to the Blaze or Flame plans you need billing enabled to allow external requests. For more information have a look at the pricing page.

Set the algolia.app_id and algolia.api_key Google Cloud environment variables to match the Algolia application ID and API key of your account. For this use:

firebase functions:config:set algolia.app_id="myAlgoliaAppId" algolia.api_key="myAlgoliaApiKey"