Quickstart
Create a transformation, destination, and task for a public product dataset, then run a Node.js script that pushes the records through the connector. The script usespushTask to identify the connector task explicitly by its task ID.
Before you begin
Make sure you have:- An Algolia account. Create one for free if you don’t already have one.
- Node.js 22 or later and npm.
- Your Algolia Write API key.
- Your Algolia application’s analytics region:
usfor the United States oreufor Europe.
Set up the Push to Algolia connector
1
Open the Push to Algolia connector
Go to the Algolia dashboard and select your Algolia .
On the left sidebar, select Data sources,
then open the Connectors page.
2
Connect the source
Select Push to Algolia, then select Connect.
3
Transform the records
This transformation adds a Save the transformation.
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
Select index and credentials
Select Create a new destination to choose an for the connector to store records.Under Connect your data to Algolia Search, enter
quickstart-products and,
under Index credentials,
select Create one for me.5
Create the destination
In Name, enter
Quickstart push destination and select Create destination.6
Create the task
Select Create task.
The dashboard opens API Client & Code snippets with a generated
pushTask example.Copy the taskID value from the example, then select Close.Continue with the next step instead of copying the generated records or code.
The next steps use environment variables to keep your API key out of the source code.7
Create a Node.js project
In a terminal, create a project and install the Algolia API client and
dotenv:Command line
8
Add your Algolia credentials
Create a Set the variables to your Algolia application ID, write API key, analytics region, and task ID.To keep your Write API key secret,
create a
.env file in the project directory:.env
.gitignore file in the project directory:.gitignore
9
Push the sample records
Create a Run the script:Copy the Run ID printed by the script.
push.mjs file with this code:push.mjs
Command line
10
Verify the indexing operation
Open the Connector Debugger and search for the run ID printed by
push.mjs.
Confirm that the operation completed successfully.Open the quickstart-products index in the Algolia dashboard.
Confirm that it contains 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 start the UI steps in that quickstart, configure
product_type as a facet for the quickstart-products index.Use the connector with your app
In production, replace the quickstart data request inpush.mjs with code that selects records from your app or data pipeline.
For example, supply records from a processing job or a source for which Algolia doesn’t provide another connector.
Prepare your records
Send only the records required by the indexing operation. For example, your app can send a changed record after updating its source data instead of exporting and synchronizing the full dataset. Ensure each record has a stable, uniqueobjectID.
If your source uses a different unique property, map it before pushing the records:
JavaScript
searchableAttributes,
attributesForFaceting, or
customRanking.
Choose an API client method
Choose a method based on how you want to identify the connector task and update the index.push,chunkedPush, and theWithTransformationhelper methods select a user-created Push to Algolia task by index name. They support one user-created Push to Algolia connector, including when the index also uses Collections.- If multiple destinations link to the index or multiple user-created Push to Algolia connectors target it, use
pushTaskand specify the task ID. To send records through the Collections pipeline, use its task ID withpushTask.
Push with the Ingestion API
Use the Ingestion API client to choose the indexing action or identify a connector task by ID.Push by task ID
UsepushTask to select a connector task by its task ID.
Push by index name
Usepush when one task targets the specified index.
The request returns an error if no task or more than one task matches the index name.
Push records in batches
UsechunkedPush to split a large record set into batches and send each batch with push.
The default batch size is 1,000 records.
Use it directly when you need more control over the indexing action or batch size.
Search API WithTransformation methods
Use the Search API client helpers to adapt an existing implementation that calls saveObjects, partialUpdateObjects, or replaceAllObjects.
The helpers route records through the Push to Algolia connector and automatically split them into batches.
They’re subject to the connector limits.
To run the examples, install the latest API client.
Set up transformation options
Before calling aWithTransformation method, configure transformationOptions with your Algolia application’s analytics region.
The API client throws an error if you omit transformationOptions.
transformationOptions creates a dedicated ingestion transporter that starts from the Ingestion API defaults:
25-second timeouts, hosts derived from the region, and no compression.
It only overrides the options you set and doesn’t inherit the Search API client’s configuration.
For more information, see
Transformation options and the ingestion transporter.
transformationOptions replaces the deprecated setTransformationRegion method in Java,
C#,
and PHP,
the set_transformation_region method in Python,
and the transformation option in JavaScript.Add or replace records with a transformation
To add or replace complete records with a transformation, callsaveObjectsWithTransformation.
Add or update record attributes with a transformation
To add or update selected attributes with a transformation, callpartialUpdateObjectsWithTransformation.
Replace all records with a transformation
To replace all records with a transformation, callreplaceAllObjectsWithTransformation.
Supported indexing actions
The Push to Algolia connector supports all values of theaction property for batch indexing operations.
For deleteObject, delete, and clear actions,
the connector skips the transformation and uses
traditional indexing.
Connector Debugger
To debug push operations:- Check incoming events in the Connector Debugger.
The
runIDreturned by a successfulpushorpushTaskrequest identifies the indexing operation. - To wait for a
pushorpushTaskoperation and receive its result in the response, add thewatchparameter. The response reports successful and failed operations.