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
string
required
Name of the index to update records in.
IEnumerable<T>
required
Records to update.
Type parameter
required
The model of your index’s records.
bool
required
Whether to add new records to the index if they don’t exist yet.
bool
default:false
Whether to wait until all batch requests are done.
CancellationToken
default:"default"
Parameter that can be used as a signal to cancel this request.
string
required
Name of the index to update records in.
[]map[string]any
required
Records to update.
PartialUpdateObjectsOption
Functional options to provide extra arguments.
Show available functions
Show available functions
function
Signature:
func(createIfNotExists bool) partialUpdateObjectsOptionWhether to add new records to the index if they don’t exist yet.
By default, this function returns true.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(withWaitForTasks bool) chunkedBatchOptionWhether to wait until all batch requests are done.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 update records in.
Iterable<T>
required
Records to update.
Type parameter
required
The model of your index’s records.
boolean
default:false
Whether to add new records to the index if they don’t exist yet.
bool
default:false
Whether to wait until all batch requests are done.
RequestOptions
Additional request options.
string
required
Name of the index to update records in.
Record<string,unknown>[]
required
Records to update.
boolean
default:"undefined"
Whether to add new records to the index if they don’t exist yet.
boolean
default:false
Whether to wait until all batch requests are done.
RequestOptions
Additional request options.
String
required
Name of the index to update records in.
List<JsonObject>
required
Records to update.
Boolean
required
Whether to add new records to the index if they don’t exist yet.
Boolean
default:false
Whether to wait until all batch requests are done.
RequestOptions
Additional request options.
string
required
Name of the index to update records in.
array
required
Records to update.
bool
required
Whether to add new records to the index if they don’t exist yet.
array
Additional request options.
str
required
Name of the index to update records in.
list[dict]
required
Records to update.
bool
default:false
Whether to add new records to the index if they don’t exist yet.
bool
default:"False"
Whether to wait until all batch requests are done.
dict | RequestOptions
Additional request options.
String
required
Name of the index to update records in.
Array[Hash]
required
Records to update.
Boolean
Whether to add new records to the index if they don’t exist yet.
Boolean
default:false
Whether to wait until all batch requests are done.
Hash
Additional request options.
String
required
Name of the index to update records in.
Seq[Any]
required
Records to update.
Boolean
default:false
Whether to add new records to the index if they don’t exist yet.
Boolean
default:false
Whether to wait until all batch requests are done.
RequestOptions
Additional request options.