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
string
required
Name of the index to which to add records.
IEnumerable<T>
required
Records to add.
type parameter
required
The model of your index’s records.
bool
default:false
Whether to wait until all batch requests are done.
int
default:1000
Number of records to process in one batch.
RequestOptions
Additional request options.
string
required
Name of the index to which to add records.
[]map[string]any
required
Records to add.
ChunkedBatchOption
Functional options to provide extra arguments.
Show available functions
Show available functions
function
Signature:
func(waitForTasks bool) chunkedBatchOptionWhether to wait until all batch requests are done.function
Signature:
func(batchSize int) chunkedBatchOptionNumber of records to process in one batch.function
Signature:
func(key string, value string) requestOptionSets extra header parameters for this request.function
Signature:
func(key string, value string) requestOptionSets extra query parameters for this request.String
required
Name of the index to which to add records.
Iterable<T>
required
Records to add.
Type parameter
required
The model of your index’s records.
boolean
default:false
Whether to wait until all batch requests are done.
int
default:1000
Number of records to process in one batch.
RequestOptions
Additional request options.
string
required
Name of the index to which to add records.
Record<string,unknown>[]
required
Records to add.
boolean
default:false
Whether to wait until all batch requests are done.
number
default:1000
Number of records to process in one batch.
RequestOptions
Additional request options.
String
required
Name of the index to which to add records.
List<JsonObject>
required
Records to add.
Boolean
default:false
Whether to wait until all batch requests are done.
Int
default:1000
Number of records to process in one batch.
RequestOptions
Additional request options.
string
required
Name of the index to which to add records.
array
required
Records to add.
bool
default:false
Whether to wait until all batch requests are done.
int
default:1000
Number of records to process in one batch.
array
Additional request options.
str
required
Name of the index to which to add records.
list[dict]
required
Records to add.
bool
default:"False"
Whether to wait until all batch requests are done.
int
default:1000
Number of records to process in one batch.
dict | RequestOptions
Additional request options.
String
required
Name of the index to which to add records.
Array[Hash]
required
Records to add.
Boolean
default:false
Whether to wait until all batch requests are done.
Integer
default:1000
Number of records to process in one batch.
Hash
Additional request options.
String
required
Name of the index to which to add records.
Seq[Any]
required
Records to add.
Boolean
default:false
Whether to wait until all batch requests are done.
Int
default:1000
Number of records to process in one batch.
Option[RequestOptions]
Additional request options.