Algolia App Installation Guide

Algolia is an AI-powered search and discovery platform for dynamic experiences. It helps businesses discover and access the necessary content quicker and more efficiently, boosting business performance, especially if you are an e-commerce brand.

Contentstack Marketplace lets you install and use the Algolia application to update Algolia indices whenever entries and assets are published, unpublished, or deleted in Contentstack.

Prerequisites

This step-by-step guide explains how to install and configure Algolia within your stack.

Steps for Execution

  1. Retrieve Algolia Credentials
  2. Install and Configure Algolia in Contentstack Marketplace
  3. Use Algolia within your Stack
  1. Retrieve Algolia Credentials

    To configure the Algolia app, you must get the application_id, index name and API key from Algolia. To do that, follow the steps given below:

    1. Log in to your Algolia account.
    2. Click the Settings button in the left navigation bar; open the API Keys option under Team and Access.

      Keys are available here if you have already created them:
      API-Key.png

      Note: When creating new API keys, select the Indices.
      Also, provide the ACL options to perform indexing, as shown below:

      Update-Indices.png
      ACL-Object-List.png

    3. On the API Keys page, you will get an Application ID, copy the Application ID and note it down, and you will need it to configure your app in Contentstack.
      Application-ID-APIKey.png
    4. Click the copy icon in the search dashboard to save or copy the index name as shown below:
      Copy-Index-Name.png

      Now that you have the required credentials to configure the app go to Contentstack and set up the app.
  2. Install and Configure Algolia in Contentstack Marketplace

    To install the application in Contentstack, follow the steps below:

    1. Log in to your Contentstack account.
    2. On the left-hand side of primary navigation, you will find the Marketplace icon (as shown below). Click the icon to go to the Marketplace.
      Select-Marketplace-Icon.png
    3. Within the Marketplace, you can see all the apps available; hover over the Algolia app and click the Install App button. 
      Install-Algolia-App.png
    4. On the next screen, select the stack where you want to install the Algolia app, click the checkbox to agree to the Terms of Service and Privacy Policy, and click Install.
      Algolia-Authorization.png
    5. On the Configuration page, select the environment and enter the Algolia credentials we retrieved in step 1.

      Note: Credentials entered for an environment will be applicable to the entries published on that environment.

      Algolia-Configuration.png
    6. Click the Add Configuration button to add more configurations.
    7. If you want to add only specific content types with selected mapping rules/fields or control the behavior of content type entries and Asset(s) that are added to Algolia indices, then click the Additional settings toggle and add rules.
      Algolia-Configuration-Additional-Details.png

      Note: Ensure that you add at least one configuration before you go for additional settings.

    8. Click the Add Rule button to add one or more rules by selecting the content type and appropriate mapping fields.

      Note: The app will add entries to Algolia Index only for the content types added in the mapping rule(s). Also, the added rules(s) will apply to all environments selected in the previous configuration.

    9. Mark the Select for all Content Types checkbox if you want to add entries to Algolia Index for all the content types along with the content types for which you set the rules by selecting Mapping Fields.
      If you select this option
      , the app will perform the following actions:
      • The app adds the entries of content types specified in Mapper to Algolia according to the rules/fields added.
      • The app adds the entries of content types not added to Mapper to Algolia with all their data.
      If you deselect this option, the app will perform the following actions:
      • The data for all content type entries will not be added to Algolia.
      • If the content type Mapping has not been provided then content type webhook will be disabled and no data from content type entries will be added.
    10. Mark the Select for Asset(s) checkbox if you want to add Asset(s) to Algolia Index.
      This option will add your assets' data to the Algolia Index on publishing. Similarly, this option can remove your data from the Algolia Index when unpublished/deleted from Contentstack.

      Note: If this option is not selected, Asset(s) data will not be added to Algolia.


      Select-Assets.png

      Using the + Add Field option in the Mapping Fields dropdown, you can map nested or complex structures in the following manner:

      • While mapping nested fields, you must specify the object and its field using the dot(.) notation.

        For example, Object.age for accessing the age field within the object.
      • While mapping arrays, use indexing.
        For example, Array[1] for accessing the second value of an array.Add-Field.png

      You can use the above rules to create mapping rules for complex structures that include objects and arrays.

      Add-Mapping-Field-Option.png

      All Contentstack fields are supported through this feature. For reference complex field, only single level nesting is supported.

      Example:

      "reference": [
      {
      "uid": "bltxxxxxxxxxxxx",
      "_content_type_uid": "example_content_type"
      }
      ]

      If we have a reference field named reference, then reference[0].title will give the title of the reference field selected.

    11. Save the changes and click the Open Stack button to start using the Algolia application.
  3. Use Algolia within your Stack

    To use the Algolia application in an entry of your stack, follow the steps given below:

    1. Go to your stack, click the Content Models icon on the left navigation panel, and click the + New Content Type button.
    2. Create a content type by adding relevant details and clicking the Save and proceed button.
      Create-New-Content-Type.png
    3. On the Content Type Builder page, add the required fields in your content type. Now create an entry within the content type we just created and add details as shown below:
      Content-Type-Builder-Page.png
    4. Save your entry and publish it in the environment selected while configuring the app in step 2.
      Publish-Entry.png

      Note: Publish the entries only in the environment(s) you selected while configuring the Algolia app.

    5. Navigate to the Index section in your Algolia account to see the published entry.
      Algolia-Account.png

    Note: If you unpublish/delete an entry on a specified environment, the app deletes the entry from Algolia's index.
    If you delete a content type from your stack, the app deletes all the published entries of that content type which you added to Algolia from Algolia's index (applies only when Additional Settings are enabled).
    Delete content type and Asset will only work when there is faceting for _content_type and uid in that index.

    View Algolia analytics in the dashboard (This is optional)

    The dashboard displays data coming from multiple environments of the Algolia app.

    1. On the Configuration page, select the environment you want to make the default environment.
      Select-Publishing-Environment.png

      Note: If you don't choose a default environment, then the first environment in the configuration will be displayed as the default environment in the dashboard.

    2. In the dashboard, select the dropdown in the top-right corner of the table to display data for a specific environment.
    3. You can view the data for Top Searches and Top Searches With No Results by switching between the tabs.
      Top-Searches.png

Was this article helpful?

Thanks for your feedbackSmile-icon

More articles in "Search and Discovery Platforms"

On This Page

^