Algolia

From this guide, you’ll learn how to index Prepr content with the Algolia search engine for an optimized and performant search experience in your web app.

The Algolia integration is available as a paid option on top of your regular subscription. Please contact our Sales team for more details.

Introduction

If you value a good customer experience, you might think about how web visitors search across your app. Can they easily find what they are looking for? Are they receiving the most up-to-date content? Web users have a short attention span, so it's crucial to provide them with relevant search results to maintain their loyalty.

Prepr supports integration with Algolia, an AI-powered search service with a high-performance API. It enables your Prepr content items to be indexed using the Algolia algorithm, maximizing the search speed and content discovery in your web app.

To make it easier to use, here are the step-by-step instructions.

Step 1: Get the API credentials from your Algolia app

To connect Prepr to Algolia, you need an Application ID and a valid API key with the permissions to add and delete Algolia records. For more details, check out Rights and restrictions in Algolia docs. Algolia uses these credentials to identify your Prepr application and control access to Algolia’s API.

To get the credentials, navigate to the API Keys section in your Algolia app settings.

Step 2: Connect Prepr to Algolia

Now that you have the required credentials, you can set up the Algolia integration in Prepr as follows:

  1. Go to Settings > Integrations and choose Algolia. Click the Activate button.

If you do not have access to the Algolia integration yet, click Request activation. Our Sales team will get in touch with you shortly to activate your request.

  1. In the New Algolia app page, enter your Algolia credentials from the previous step.

  2. Select the models you want to sync to Algolia and map them to the required Algolia index names.

You can specify the existing index names you already have in your Algolia, or you can provide new index names from within Prepr. In the latter case, the indices with the relevant names will be created automatically once the data is synced to Algolia. Read more about the Algolia indices.

4. Click Save to confirm the settings.

Connect to Algolia

That's it. You’ve connected Prepr to Algolia. From now on, Prepr will automatically keep syncing your content items to Algolia for indexing.

When a new content item is published, a new record will be created in Algolia. Any changes to the published content item result in updating the corresponding Algolia record. Once the content item is unpublished, the Algolia record will be removed.

So you can be sure your data is always-in-sync, and that the most up-to-date content is available to your web app visitors.

Note

Changes to content item structure (i.e., schema) won't be synced to Algolia automatically. In this case, you must run the sync manually. Please read more on how to sync schema updates to Algolia.

Indexed field types

Before sending your content item data to Algolia, Prepr automatically transforms it into a JSON format that Algolia recognizes. Once data is prepared and synced, the corresponding records are created and stored in an Algolia index you specified in Step 2.

The following table shows indexed Prepr field types and the corresponding Algolia records types.

Prepr field types
Algolia records
TextString
BooleanBoolean
FloatFloat
IntegerInteger
Dynamic contentString

Note: All text fields in the Dynamic content field will be merged into a single string.
Content referenceJSON object

Note: It only includes an ID and title of a content item.
AssetJSON object

Note: It only includes an asset URL.
TagList/array

Step 3: Connect your front end to Algolia

Now that your Prepr data is indexed with Algolia, you’re ready to implement Algolia on your web app.

Follow the Algolia instructions to set up the API client ​​for your programming language. After setting up the API client, you can initialize and connect it to Algolia.

Also, check out how to build a search UI with Algolia.

How to sync existing content and schema updates to Algolia

The steps above allow you to index all new content created after enabling the Algolia integration. If you need to index any content you already have, or after a schema update, you need to run the sync action manually.

To sync content items to Algolia manually, you must call the given Prepr endpoint and specify a model ID, which you can find under Schema > Model > > Copy Model ID.

Content items will be synced in batches of 1,000 in approximately 2 seconds for each batch. The overall time depends on the number of content items you have.

The following API request will sync content items to Algolia:

GET: https://api.eu1.prepr.io/publications/algolia/sync
{
   "model": {
       "id": "YOUR_MODEL_ID"
   }
}

Important

Make sure to create an access token with the REST API scopes content_items and content_items_publish and bind a user to this token under Settings > Access tokens. Please note that access tokens with write permissions must not be visible client-side. Read more in Authentication.