Data transformations is a beta feature according to Algolia’s Terms of Service (“Beta Services”)

You can add transformations to your connector’s destination to manipulate data before it’s written to your Algolia indices.

To use transformations, create a task that specifies both the data source and the destination (usually an Algolia index). You can add a transformation when creating the task or directly to an existing destination.

To learn more about connectors, see Connectors overview.

Transformations are written as small JavaScript functions. See the limits section for more information about their runtime limitations.

Only one transformation can be added to a destination.

Get started

  1. Go to the Algolia dashboard and select your Algolia application.
  2. On the left sidebar, select Data sources.
  3. Open the Connectors page.
  4. Select a connector and click Connect to start creating your task.
  5. Configure your data source: create a new source or select an existing one.
  6. To create your transformation function, click Create transformation. When writing a transformation, you have these choices:
    • Write your own functions directly in the code editor, which includes autocompletion and syntax highlighting.
    • Use predefined helper functions for common Algolia-specific tasks. To use a helper function, click Helper functions and select from the list. For more information, see Helper functions.
  7. Configure your destination: create a new destination or select an existing one.
  8. Configure when your task should run and specify the operation type for writing your Algolia index records.
  9. Confirm whether you want to run your task immediately. To see your transformation in action, click Run and inspect your index records after the task completes.

Helper functions

The following helper transformations are available to use, or extend, in your own transformations.

Helper typeDescription
ReshapeIncludes functions for adding, or removing attributes from a record.
FiltersExclude records based on a condition.
ConvertChange the data type of attributes, trim or normalize them, and convert data types to a specific ISO format.
ComputeNew properties: calculate a discounted price and show as a new discount attribute.
RankingCompute a gravity/decay ranking to help with custom ranking outcomes, compute a weighted value ranking for custom ranking.
Query CategorizationManage hierarchical categories by converting a flat list into a hierarchical structure.

Preview transformation results

When you create a transformation, you can preview the function on the right side of the code editor.

The preview includes the following information:

  • Input Record. A sample record, taken from the data source before applying the transformation.

  • Transformation Preview. Click Try it out to see the results of your transformation on the sample record.

Not all connectors support fetching sample records.

Debug transformations

Use the Connector Debugger for insights into the status of your tasks, including transformations.

Limits

The runtime environment for transformations has the following limits:

ParameterDescription
Run time1 second per transformation
Memory100 kB per transformation