Before you begin
If you don’t have an Algolia account, create one for free.Index a sample dataset with the CSV connector
Create a source, destination, transformation, and synchronization task for the sample product dataset.- The source tells the connector where to fetch the CSV 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 CSV connector
Go to the Algolia dashboard and select your Algolia application.
Open the Connectors page.Find CSV, then select Connect.
2
Configure the CSV source
Under Configure your data source, select Create a new source.Under Is your data source protected?, select None.In URL, enter:For HTTP Method, select GET.
3
Configure column types
In Unique column identifier, enter
objectID.Under Column type mapping, add these columns and select the corresponding type:4
Create the CSV source
In Connector name, enter
Quickstart products CSV source, then select Create source.5
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
6
Choose the destination index
Under Configure your destination, select Create a new destination.Under Search, enter
quickstart-products as the index name.7
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 ACLs.In Name, enter CSV quickstart products destination, then select Create destination.8
Create an on-demand synchronization task
Under Configure your task, select On demand and Full reindexing.Select Create task, then Run and wait for the task to finish.
9
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 build the UI,
configure
product_type as an attribute for faceting in the quickstart-products index.Index your own CSV data
To index your own records, update the connector source URL to point to a CSV file you host. After you update the source, run the connector task again to index your records.Source file format
The first row of your CSV file must contain the column names. Each remaining row represents one record. For example:CSV
objectID attribute. In the source configuration, use Unique property identifier to set this attribute. Choose a column whose values are unique for every row (id in this example).
Enclose fields that contain commas, double quotation marks, or line breaks in double quotation marks.
For more information, see Common Format and MIME Type for Comma-Separated Values (CSV) Files
.
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.