addObject
This helper method uses the Batch operations on one index operation.
It builds a batch request with either the partialUpdateObject or partialUpdateObjectNoCreate action,
depending on whether createIfNotExists is true or false.
The method sends records in batches of up to 1,000.
This operation is subject to indexing rate limits.
Usage
var response = await client.PartialUpdateObjectsAsync(
"INDEX_NAME",
new List<Object>
{
new Dictionary<string, string> { { "objectID", "1" }, { "name", "Adam" } },
new Dictionary<string, string> { { "objectID", "2" }, { "name", "Benoit" } },
},
true
);
response, err := client.PartialUpdateObjects(
"INDEX_NAME",
[]map[string]any{{"objectID": "1", "name": "Adam"}, {"objectID": "2", "name": "Benoit"}}, search.WithCreateIfNotExists(true))
if err != nil {
// handle the eventual error
panic(err)
}
List response = client.partialUpdateObjects(
"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.partialUpdateObjects({
indexName: 'cts_e2e_partialUpdateObjects_javascript',
objects: [
{ objectID: '1', name: 'Adam' },
{ objectID: '2', name: 'Benoit' },
],
createIfNotExists: true,
});
var response =
client.partialUpdateObjects(
indexName = "INDEX_NAME",
objects =
listOf(
buildJsonObject {
put("objectID", JsonPrimitive("1"))
put("name", JsonPrimitive("Adam"))
},
buildJsonObject {
put("objectID", JsonPrimitive("2"))
put("name", JsonPrimitive("Benoit"))
},
),
createIfNotExists = true,
)
$response = $client->partialUpdateObjects(
'INDEX_NAME',
[
['objectID' => '1',
'name' => 'Adam',
],
['objectID' => '2',
'name' => 'Benoit',
],
],
true,
);
response = client.partial_update_objects(
index_name="INDEX_NAME",
objects=[
{
"objectID": "1",
"name": "Adam",
},
{
"objectID": "2",
"name": "Benoit",
},
],
create_if_not_exists=True,
)
response = client.partial_update_objects(
"INDEX_NAME",
[{objectID: "1", name: "Adam"}, {objectID: "2", name: "Benoit"}],
true
)
val response = Await.result(
client.partialUpdateObjects(
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"))))
),
createIfNotExists = true
),
Duration(100, "sec")
)
let response = try await client.partialUpdateObjects(
indexName: "INDEX_NAME",
objects: [["objectID": "1", "name": "Adam"], ["objectID": "2", "name": "Benoit"]],
createIfNotExists: true
)
Parameters
- C#
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
Name of the index to update records in.
Records to update.
The model of your index’s records.
Whether to add new records to the index if they don’t exist yet.
Whether to wait until all batch requests are done.
Parameter that can be used as a signal to cancel this request.
Name of the index to update records in.
Records to update.
Functional options to provide extra arguments.
Show available functions
Show available functions
Signature:
func(createIfNotExists bool) partialUpdateObjectsOptionWhether to add new records to the index if they don’t exist yet.
By default, this function returns true.Signature:
func(batchSize int) chunkedBatchOptionSets the number of records to process in one batch.
The default batch size is 1,000.Signature:
func(withWaitForTasks bool) chunkedBatchOptionWhether to wait until all batch requests are done.Signature:
func(key string, value string) requestOptionSets extra header parameters for this request.
To learn more, see request options.Signature:
func(key string, value string) requestOptionSets extra query parameters for this request.
To learn more, see request options.Name of the index to update records in.
Records to update.
The model of your index’s records.
Whether to add new records to the index if they don’t exist yet.
Whether to wait until all batch requests are done.
Additional request options.
Name of the index to update records in.
Records to update.
Whether to add new records to the index if they don’t exist yet.
Whether to wait until all batch requests are done.
Additional request options.
Name of the index to update records in.
Records to update.
Whether to add new records to the index if they don’t exist yet.
Whether to wait until all batch requests are done.
Additional request options.
Name of the index to update records in.
Records to update.
Whether to add new records to the index if they don’t exist yet.
Additional request options.
Name of the index to update records in.
Records to update.
Whether to add new records to the index if they don’t exist yet.
Whether to wait until all batch requests are done.
Additional request options.
Name of the index to update records in.
Records to update.
Whether to add new records to the index if they don’t exist yet.
Whether to wait until all batch requests are done.
Additional request options.
Name of the index to update records in.
Records to update.
Whether to add new records to the index if they don’t exist yet.
Whether to wait until all batch requests are done.
Additional request options.
Name of the index to update records in.
Records to update.
Whether to add new records to the index if they don’t exist yet.
Whether to wait until all batch requests are done.
Additional request options.