addObject action and automatically sends records in batches of 1,000.
This method is subject to indexing rate limits.
Usage
var response = await client.SaveObjectsAsync(
"INDEX_NAME",
new List<Object>
{
new Dictionary<string, string>
{
{ "objectID", "1" },
{ "visibility", "public" },
{ "name", "Hot 100 Billboard Charts" },
{ "playlistId", "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f" },
{ "createdAt", "1500240452" },
},
},
false,
1000,
new RequestOptionBuilder().AddExtraHeader("X-Algolia-User-ID", "*").Build()
);
response, err := client.SaveObjects(
"INDEX_NAME",
[]map[string]any{
{
"objectID": "1",
"visibility": "public",
"name": "Hot 100 Billboard Charts",
"playlistId": "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f",
"createdAt": "1500240452",
},
},
search.WithWaitForTasks(false),
search.WithBatchSize(1000),
search.WithHeaderParam("X-Algolia-User-ID", "*"),
)
if err != nil {
// handle the eventual error
panic(err)
}
List response = client.saveObjects(
"INDEX_NAME",
Arrays.asList(
new HashMap() {
{
put("objectID", "1");
put("visibility", "public");
put("name", "Hot 100 Billboard Charts");
put("playlistId", "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f");
put("createdAt", "1500240452");
}
}
),
false,
1000,
new RequestOptions().addExtraHeader("X-Algolia-User-ID", "*")
);
const response = await client.saveObjects(
{
indexName: 'playlists',
objects: [
{
objectID: '1',
visibility: 'public',
name: 'Hot 100 Billboard Charts',
playlistId: 'd3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f',
createdAt: '1500240452',
},
],
waitForTasks: false,
batchSize: 1000,
},
{
headers: { 'X-Algolia-User-ID': '*' },
},
);
var response =
client.saveObjects(
indexName = "INDEX_NAME",
objects =
listOf(
buildJsonObject {
put("objectID", JsonPrimitive("1"))
put("visibility", JsonPrimitive("public"))
put("name", JsonPrimitive("Hot 100 Billboard Charts"))
put("playlistId", JsonPrimitive("d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f"))
put("createdAt", JsonPrimitive("1500240452"))
}
),
waitForTasks = false,
batchSize = 1000,
requestOptions = RequestOptions(headers = buildMap { put("X-Algolia-User-ID", "*") }),
)
$response = $client->saveObjects(
'INDEX_NAME',
[
['objectID' => '1',
'visibility' => 'public',
'name' => 'Hot 100 Billboard Charts',
'playlistId' => 'd3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f',
'createdAt' => '1500240452',
],
],
false,
1000,
[
'headers' => [
'X-Algolia-User-ID' => '*',
],
]
);
response = client.save_objects(
index_name="INDEX_NAME",
objects=[
{
"objectID": "1",
"visibility": "public",
"name": "Hot 100 Billboard Charts",
"playlistId": "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f",
"createdAt": "1500240452",
},
],
wait_for_tasks=False,
batch_size=1000,
request_options={
"headers": loads("""{"X-Algolia-User-ID":"*"}"""),
},
)
response = client.save_objects(
"INDEX_NAME",
[
{
objectID: "1",
visibility: "public",
name: "Hot 100 Billboard Charts",
playlistId: "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f",
createdAt: "1500240452"
}
],
false,
1000,
{:header_params => {"X-Algolia-User-ID" => "*"}}
)
val response = Await.result(
client.saveObjects(
indexName = "INDEX_NAME",
objects = Seq(
JObject(
List(
JField("objectID", JString("1")),
JField("visibility", JString("public")),
JField("name", JString("Hot 100 Billboard Charts")),
JField("playlistId", JString("d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f")),
JField("createdAt", JString("1500240452"))
)
)
),
waitForTasks = false,
batchSize = 1000,
requestOptions = Some(
RequestOptions
.builder()
.withHeader("X-Algolia-User-ID", "*")
.build()
)
),
Duration(100, "sec")
)
let response = try await client.saveObjects(
indexName: "INDEX_NAME",
objects: [[
"objectID": "1",
"visibility": "public",
"name": "Hot 100 Billboard Charts",
"playlistId": "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f",
"createdAt": "1500240452",
]],
waitForTasks: false,
batchSize: 1000,
requestOptions: RequestOptions(
headers: ["X-Algolia-User-ID": "*"]
)
)
Parameters
- C#
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
Name of the index to which to add records.
Records to add.
The model of your index’s records.
Whether to wait until all batch requests are done.
Number of records to process in one batch.
Additional request options.
Name of the index to which to add records.
Records to add.
Functional options to provide extra arguments.
Show available functions
Show available functions
Signature:
func(waitForTasks bool) chunkedBatchOptionWhether to wait until all batch requests are done.Signature:
func(batchSize int) chunkedBatchOptionNumber of records to process in one batch.Signature:
func(key string, value string) requestOptionSets extra header parameters for this request.Signature:
func(key string, value string) requestOptionSets extra query parameters for this request.Name of the index to which to add records.
Records to add.
The model of your index’s records.
Whether to wait until all batch requests are done.
Number of records to process in one batch.
Additional request options.
Name of the index to which to add records.
Records to add.
Whether to wait until all batch requests are done.
Number of records to process in one batch.
Additional request options.
Name of the index to which to add records.
Records to add.
Whether to wait until all batch requests are done.
Number of records to process in one batch.
Additional request options.
Name of the index to which to add records.
Records to add.
Whether to wait until all batch requests are done.
Number of records to process in one batch.
Additional request options.
Name of the index to which to add records.
Records to add.
Whether to wait until all batch requests are done.
Number of records to process in one batch.
Additional request options.
Name of the index to which to add records.
Records to add.
Whether to wait until all batch requests are done.
Number of records to process in one batch.
Additional request options.
Name of the index to which to add records.
Records to add.
Whether to wait until all batch requests are done.
Number of records to process in one batch.
Additional request options.
Name of the index to which to add records.
Records to add.
Whether to wait until all batch requests are done.
Number of records to process in one batch.
Additional request options.