Before you begin
Make sure you have:- An Algolia account. Create one for free if you don’t already have one.
- A Supabase project with the sample data in a
public.appareltable. Download the Algolia apparel sample data and follow Supabase’s data import instructions. UseobjectIDas the table’s primary key.
Set up the Supabase connector
Create a source, transformation, destination, and synchronization task.1
Choose the Supabase connector
Go to the Algolia dashboard and select your Algolia application.Open the Connectors page.Find Supabase and select Connect.
Under Quick setup, select Connect Supabase.
2
Configure the Supabase source
For Select a project,
choose the project containing the
public.apparel table.
The connector copies Host, Port, Session Pooler Port, Database Name, Username, and Password values from your Supabase project.For SSL modes, select Prefer.In Connector name,
enter Quickstart products Supabase source,
then select Create source.3
Transform the records
This transformation adds a Select Save.
price_range attribute to each record.
After the connector indexes your records, you can display price_range or configure it as a facet.Select Transform using the code editor and replace the placeholder Transformation code with this function:JavaScript
4
Choose the destination index
Under Configure your destination,
select Create a new destination.Under Search,
enter
quickstart-products as the index name.5
Create the destination
Under Index credentials,
select Create one for me.To use an existing API key,
choose one with the
addObject, deleteIndex, and editSettings
access control list permissions.In Name,
enter Supabase quickstart products destination,
then select Create destination.6
Create and run an on-demand synchronization task
Under Configure your task,
select On demand and clear Scheduled.Select Full reindexing.Select
apparel as the source table.
Select all columns.
For ObjectID, select objectID.Select Create task,
then Run,
and wait for the task to finish.7
Verify the indexed records
Open the
quickstart-products index in the Algolia dashboard.Check that the index contains the imported product records,
with attributes such as title, description, product_type,
price, price_range, and showcase_image.You can use this index as the data source for
Build your first search experience.Before you build the UI,
configure
product_type as an attribute for faceting
in the quickstart-products index.Index your own Supabase data
To index your own data:- Use a populated Supabase table or view that the connector credentials can read.
- Follow the quickstart steps to create the source, destination, and task. Replace the sample project, table, credentials, and destination index with your own values.
- Review or remove the sample transformation so that it matches your record structure. When you configure the task, select the columns you want to include in your Algolia records.
- Select the column to use as the Algolia
objectID. This column must be present in every row, and its value must be unique and stable.
Supabase database credentials
The quickstart uses the database settings imported from your Supabase project. For your own data, create a dedicated Postgres login role for the connector. Grant the role permission to:- Connect to the database.
- Use the schema that contains the source data.
- Run
SELECTqueries on each table or view the connector needs to read.
SELECT policy that lets the connector role read the rows you want to index.
For more information, see Postgres roles and
Row Level Security.
Configure the connector username
Supabase’s session pooler details show the username for the defaultpostgres role.
When you configure the source,
replace postgres with the dedicated connector role name,
but keep the project reference after the period.
For example, for a connector role named algolia_connector,
replace postgres.PROJECT_REFERENCE with algolia_connector.PROJECT_REFERENCE.
Combine data with a Postgres view
An Algolia record can combine data from several Supabase tables. For example, a product record might combine product details with review ratings and recent order data. If your source data spans multiple tables, create a Postgres view that joins and aggregates the required data. Then, select the view as the source when you configure the synchronization task. Make sure each row in the view includes a unique, stable column that you can use as the AlgoliaobjectID.
This example creates a view that combines data from the apparel and reviews tables.
SQL
Transformations
Use transformations to add computed attributes or change values before the connector indexes your records. To use a transformed attribute for search, faceting, or ranking, update the relevant index settings, such assearchableAttributes, attributesForFaceting, or customRanking.
Test transformations with repeated task runs.
Transformations that read from and write to the same attribute,
or extract a value and then delete the source attribute,
can produce different results when the task runs again.
Synchronization schedule
After you create a task, you can edit it in the Algolia dashboard to choose when the connector runs:- On demand. Run the connector manually.
- Scheduled. Select a predefined schedule or enter a custom cron expression.
