Before you begin
If you don’t have an Algolia account, create one for free.Set up the JSON connector
Create a source, destination, transformation, and synchronization task for the sample product dataset.- The source tells the connector where to fetch the JSON file.
- The destination tells the connector which Algolia index to write to.
- The transformation changes records before the connector indexes them.
- The task controls when the connector runs.
1
Choose the JSON connector
Connect the JSON source for the hosted sample product dataset.
- Go to the Algolia dashboard and select your Algolia application.
- Go to the Connectors page in the Algolia dashboard.
- Select the JSON connector and click Connect.
2
Configure the source URL
- Select None as your authentication method under Is your data source protected?.
- In URL, enter
https://dashboard.algolia.com/api/1/sample_datasets?type=apparel. - Select GET as the HTTP Method.
3
Create the JSON source
- In Unique property identifier, enter
objectID. - In Connector name, enter
Quickstart products JSON source. - Select Create source.
4
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
5
Create the destination index
Choose the Algolia index where the connector stores the product records.
-
Under Connect your data to Algolia Search, enter
quickstart-products. -
Under Index credentials, select Create one for me. To use an existing key, choose one with the
addObject,deleteIndex, andeditSettingsACLs. -
In Name, enter
Quickstart products destination. - Select Create destination.
6
Create an on-demand synchronization task
Select On demand and Full reindexing.
7
Run the task
Select Create task, then Run and wait for the task to finish.
8
Verify the indexed records
When the task completes, open the
quickstart-products index in the Algolia dashboard.
The index 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.Index your own JSON data
To index your own records, update the connector source URL to point to a JSON file you host. After you update the source, run the connector task again to index your records.Source file format
Your JSON file must contain an array of JSON objects. For example:JSON
id in this example).
In the source configuration, set Unique property identifier to that property so the connector can use it as the Algolia objectID.
Source file location
Update the connector source URL to point to your hosted file. The source URL can usehttp, https, ftp, ftps, or sftp.
For http or https sources, choose the request method your server expects:
- GET if your server returns the file from a standard request.
- POST if your server requires a POST request.
Source authentication
Select the authentication method for your file:- None if the file is public.
- Basic Auth if the file requires a username and password.
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.