You're viewing an archived version of our docs. Check out our current documentation →
Guides / Sending and managing data / Send and update your data / Connectors

Push to Algolia

Use the Push to Algolia connector to transform your data before indexing it to Algolia using the API clients.

Get started

  1. Go to the Algolia dashboard and select your Algolia application.
  2. On the left sidebar, select Data sources.
  3. On the Connectors page, select Push to Algolia, then click Connect.
  4. Configure your transformation: create a new one or reuse an existing one.
  5. Configure your destination: create a new one or reuse an existing one.
  6. Create the task to generate a taskID.
  7. See the usage section below to update your API client implementation.

Usage

Search API client’s WithTransformation helper methods

The helper methods are designed to be drop-in replacements of the standard API clients methods (saveObjects, partialUpdateObjects, replaceAllObjects) but all relies on the push API endpoints and are subject to the Connectors Limits.

This solution is recommended if:

  • You only have one destination linked to the index you are targeting.
  • You already have an existing implementation using the Search API client.

saveObjectsWithTransformation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import "github.com/algolia/algoliasearch-client-go/v4/algolia/search"

client, err := search.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
if err != nil {
  // The client can fail to initialize if you pass an invalid parameter.
  panic(err)
}

response, err := client.SaveObjectsWithTransformation(
  "ALGOLIA_INDEX_NAME",
  []map[string]any{map[string]any{"objectID": "1", "name": "Adam"}, map[string]any{"objectID": "2", "name": "Benoit"}}, search.WithWaitForTasks(true))
if err != nil {
  // handle the eventual error
  panic(err)
}

partialUpdateObjectsWithTransformation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import "github.com/algolia/algoliasearch-client-go/v4/algolia/search"

client, err := search.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
if err != nil {
  // The client can fail to initialize if you pass an invalid parameter.
  panic(err)
}

response, err := client.PartialUpdateObjectsWithTransformation(
  "ALGOLIA_INDEX_NAME",
  []map[string]any{map[string]any{"objectID": "1", "name": "Adam"}, map[string]any{"objectID": "2", "name": "Benoit"}}, search.WithCreateIfNotExists(true), search.WithWaitForTasks(true))
if err != nil {
  // handle the eventual error
  panic(err)
}

replaceAllObjectsWithTransformation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import "github.com/algolia/algoliasearch-client-go/v4/algolia/search"

client, err := search.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
if err != nil {
  // The client can fail to initialize if you pass an invalid parameter.
  panic(err)
}

response, err := client.ReplaceAllObjectsWithTransformation(
  "ALGOLIA_INDEX_NAME",
  []map[string]any{map[string]any{"objectID": "1", "name": "Adam"}, map[string]any{"objectID": "2", "name": "Benoit"}, map[string]any{"objectID": "3", "name": "Cyril"}, map[string]any{"objectID": "4", "name": "David"}, map[string]any{"objectID": "5", "name": "Eva"}, map[string]any{"objectID": "6", "name": "Fiona"}, map[string]any{"objectID": "7", "name": "Gael"}, map[string]any{"objectID": "8", "name": "Hugo"}, map[string]any{"objectID": "9", "name": "Igor"}, map[string]any{"objectID": "10", "name": "Julia"}}, search.WithBatchSize(3))
if err != nil {
  // handle the eventual error
  panic(err)
}

Ingestion API client’s push method

This solution is recommended if you only have one destination linked to the index you are targeting.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Ingestion;

var client = new IngestionClient(
  new IngestionConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
);

var response = await client.PushAsync(
  "ALGOLIA_INDEX_NAME",
  new PushTaskPayload
  {
    Action = Enum.Parse<Action>("AddObject"),
    Records = new List<PushTaskRecords>
    {
      new PushTaskRecords
      {
        ObjectID = "o",
        AdditionalProperties = new Dictionary<string, object>
        {
          { "key", "bar" },
          { "foo", "1" },
        },
      },
      new PushTaskRecords
      {
        ObjectID = "k",
        AdditionalProperties = new Dictionary<string, object>
        {
          { "key", "baz" },
          { "foo", "2" },
        },
      },
    },
  }
);

Ingestion API client’s pushTask method

This solution is recommended if you have multiple destinations linked to the index you are targeting.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Ingestion;

var client = new IngestionClient(
  new IngestionConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
);

var response = await client.PushTaskAsync(
  "6c02aeb1-775e-418e-870b-1faccd4b2c0f",
  new PushTaskPayload
  {
    Action = Enum.Parse<Action>("AddObject"),
    Records = new List<PushTaskRecords>
    {
      new PushTaskRecords
      {
        ObjectID = "o",
        AdditionalProperties = new Dictionary<string, object>
        {
          { "key", "bar" },
          { "foo", "1" },
        },
      },
      new PushTaskRecords
      {
        ObjectID = "k",
        AdditionalProperties = new Dictionary<string, object>
        {
          { "key", "baz" },
          { "foo", "2" },
        },
      },
    },
  }
);

Performance considerations

If you don’t need an Algolia-managed transformation, send records in the traditional way to avoid unnecessary overhead.

Supported indexing actions

The Push to Algolia connector supports all action types for batch indexing operations. For deleteObject, delete and clear actions, it skips the transformation and uses traditional indexing.

Connector Debugger

To check and debug pushTask operations:

  • Check incoming events in the Connector Debugger on the Algolia dashboard.
    • The eventID returned by a successful pushTask API call shows the status of the indexing operation.
  • To get real-time feedback, add the watch parameter to the pushTask API call. The response body reports errors and successes.

Limitations

This connector is subject to the following limitations: