addObject
Before using this method, set up transformation options on the search client.
To use this method, you must have only one Push to Algolia connector.
The API returns a 400 error if you have more than one Push connector,
or you use Collections and a Push connector.
For more information, see WithTransformation helper methods.
This helper method creates push tasks with
the addObject action and sends these requests in batches of 1,000.
This method is subject to indexing rate limits
and connector limits.
Usage
var response = await client.SaveObjectsWithTransformationAsync(
"INDEX_NAME",
new List<Object>
{
new Dictionary<string, string> { { "objectID", "1" }, { "name", "Adam" } },
new Dictionary<string, string> { { "objectID", "2" }, { "name", "Benoit" } },
},
true
);
final response = await client.saveObjectsWithTransformation(
indexName: "INDEX_NAME",
objects: [
{
'objectID': "1",
'name': "Adam",
},
{
'objectID': "2",
'name': "Benoit",
},
],
waitForTasks: true,
);
response, err := client.SaveObjectsWithTransformation(
"INDEX_NAME",
[]map[string]any{{"objectID": "1", "name": "Adam"}, {"objectID": "2", "name": "Benoit"}}, search.WithWaitForTasks(true))
if err != nil {
// handle the eventual error
panic(err)
}
List response = client.saveObjectsWithTransformation(
"INDEX_NAME",
Arrays.asList(
new HashMap() {
{
put("objectID", "1");
put("name", "Adam");
}
},
new HashMap() {
{
put("objectID", "2");
put("name", "Benoit");
}
}
),
true
);
const response = await client.saveObjectsWithTransformation({
indexName: 'cts_e2e_saveObjectsWithTransformation_javascript',
objects: [
{ objectID: '1', name: 'Adam' },
{ objectID: '2', name: 'Benoit' },
],
waitForTasks: true,
});
var response =
client.saveObjectsWithTransformation(
indexName = "INDEX_NAME",
objects =
listOf(
buildJsonObject {
put("objectID", JsonPrimitive("1"))
put("name", JsonPrimitive("Adam"))
},
buildJsonObject {
put("objectID", JsonPrimitive("2"))
put("name", JsonPrimitive("Benoit"))
},
),
waitForTasks = true,
)
$response = $client->saveObjectsWithTransformation(
'INDEX_NAME',
[
['objectID' => '1',
'name' => 'Adam',
],
['objectID' => '2',
'name' => 'Benoit',
],
],
true,
);
response = client.save_objects_with_transformation(
index_name="INDEX_NAME",
objects=[
{
"objectID": "1",
"name": "Adam",
},
{
"objectID": "2",
"name": "Benoit",
},
],
wait_for_tasks=True,
)
response = client.save_objects_with_transformation(
"INDEX_NAME",
[{objectID: "1", name: "Adam"}, {objectID: "2", name: "Benoit"}],
true
)
val response = Await.result(
client.saveObjectsWithTransformation(
indexName = "INDEX_NAME",
objects = Seq(
JObject(List(JField("objectID", JString("1")), JField("name", JString("Adam")))),
JObject(List(JField("objectID", JString("2")), JField("name", JString("Benoit"))))
),
waitForTasks = true
),
Duration(100, "sec")
)
let response = try await client.saveObjectsWithTransformation(
indexName: "INDEX_NAME",
objects: [["objectID": "1", "name": "Adam"], ["objectID": "2", "name": "Benoit"]],
waitForTasks: true
)
Parameters
- Go
- Java
- JavaScript
- PHP
- Python
string
required
Name of the index to save records to.
[]map[string]any
required
Records to save.
ChunkedBatchOption
Functional options to provide extra arguments.
Show available functions
Show available functions
function
Signature:
func(withWaitForTasks bool) chunkedBatchOptionWhether to wait until all batch requests are done.function
Signature:
func(batchSize int) chunkedBatchOptionSets the number of records to process in one batch.
The default batch size is 1,000.function
Signature:
func(key string, value string) requestOptionSets extra header parameters for this request.
To learn more, see request options.function
Signature:
func(key string, value string) requestOptionSets extra query parameters for this request.
To learn more, see request options.String
required
Name of the index to save records to.
Iterable<T>
required
Records to save.
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 save records to.
Record<string,unknown>[]
required
Records to save.
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 save records to.
array
required
Records to save.
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.