index.save_objects(Arrayobjects)
index.save_objects(Arrayobjects, Hash opts = {
Boolean auto_generate_object_id_if_not_exist: false
# Any requestOptions
})
# Add a single record
index.save_object(Hashobject)
index.save_object(Hashobject, Hash opts = {
Boolean auto_generate_object_id_if_not_exist: false
# Any requestOptions
})
index.saveObjects(arrayobjects)
index.saveObjects(arrayobjects, {
autoGenerateObjectIDIfNotExist: boolean // Any other requestOptions
})
// Update a single record
index.saveObject(objectobject)
index.saveObject(objectobject, {
autoGenerateObjectIDIfNotExist: boolean // Any other requestOptions
})
index.saveObjects(List<T>objects)
index.saveObjects(List<T>objects, RequestOptionsrequestOptions)
// Auto-generate objectID
index.saveObjects(List<T>objects, boolean true)
// Add a single record
index.saveObject(Tobject)
index.saveObject(Tobject, RequestOptionsrequestOptions)
// Auto-generate objectID
index.saveObject(Tobject, boolean true)
index.SaveObjects([]Objectobjects)
index.SaveObjects([]Objectobjects, RequestOptionsrequestOptions)
// Update a single object
index.SaveObject(Objectobject)
index.SaveObject(Objectobject, RequestOptionsrequestOptions)
index into "index_name" objects objects
index into "index_name" objects objects options requestOptions// Update a single record
index into "index_name" `object` object
index into "index_name" `object` object options requestOptions
We released a new version of the PHP API client in public beta.
Read the beta documentation for more information.
We released a new version of the JavaScript API client in public beta.
Read the beta documentation for more information.
We released a new version of the Java API client in public beta.
Read the beta documentation for more information.
You’re currently reading the JavaScript API client v4 documentation. Check the migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.
If a record doesn’t contain an objectID, Algolia automatically adds it.
If you specify an existing objectID, it completely replaces all the attributes except for objectID.
To update only some attributes of an existing record, use partialUpdateObjects instead.
Limitations
To ensure good performance, saveObjects automatically sends batches of 1,000 records. If you’re indexing many records and have a stable, high-speed internet connection, increase the batch size to send more records per request and shorten your indexing time.
To ensure good performance, saveObjects automatically sends batches of 1,000 records. If you’re indexing many records and have a stable, high-speed internet connection, increase the batch size to send more records per request and shorten your indexing time.
To ensure good performance, saveObjects automatically sends batches of 1,000 records. If you’re indexing many records and have a stable, high-speed internet connection, increase the batch size to send more records per request and shorten your indexing time.
To ensure good performance, saveObjects automatically sends batches of 1,000 records. If you’re indexing many records and have a stable, high-speed internet connection, increase the batch size to send more records per request and shorten your indexing time.
To ensure good performance, saveObjects automatically sends batches of 1,000 records. If you’re indexing many records and have a stable, high-speed internet connection, increase the batch size to send more records per request and shorten your indexing time.
To ensure good performance, saveObjects automatically sends batches of 1,000 records. If you’re indexing many records and have a stable, high-speed internet connection, increase the batch size to send more records per request and shorten your indexing time.
// With JsonObjectvaljson=listOf(buildJsonObject{put("firstname","Jimmie")put("lastname","Barninger")put("objectID","myID1")},buildJsonObject{put("firstname","Warren")put("lastname","Speach")put("objectID","myID2")})index.saveObjects(json)// With serializable classvalcontacts=listOf(MyContact("Jimmie","Barninger","myID1"),MyContact("Warren","Speach","myID2"))index.saveObjects(MyContact.serializer(),contacts)
# Add new records from a new-line delimited JSON file
algolia objects import --file records.ndjson
# Add new records from the command lineecho'{ "objectID": "myID1", "firstName": "Jimmie", "lastName": "Barninger" }\n{ "objectID": "myID2", "firstName": "Warren", "lastName": "Speach" }\n'\
| algolia objects import <INDEX> --file -
# Add new records from a JSON (array) file; format with `jq`cat records.json | jq '.[]' | algolia objects import <INDEX> --file -
// With JsonObjectvaljson=buildJsonObject{put("firstname","Jimmie")put("lastname","Barninger")put("objectID","myID")}index.saveObject(json)// / With serializable classvalcontact=Contact("Jimmie","Barninger",ObjectID("myID"))index.saveObject(Contact.serializer(),contact)
saveObjects requires an objectID unless you set autoGenerateObjectIDIfNotExist to true.
If the objectID exists, Algolia replaces the record
If the objectID is present but doesn’t exist, Algolia creates the record
If the objectID isn’t specified and autoGenerateObjectID is false (the default), the engine returns an error.
If the objectID isn’t specified and autoGenerateObjectID is true, the engine generates an objectID and returns it in the response.
In the Ruby API client, this parameter is spelled: auto_generate_object_id_if_not_exist.
objectIDKey
type: string
Optional
The objectID is set from the value of the specified key.
Only available for PHP.
requestOptions
type: key-value mapping
default: No request options
Optional
A mapping of requestOptions to send along with the query. In addition to sending extra HTTP headers or setting timeouts, you can use requestOptions to set autoGenerateObjectIDIfNotExist.
objects âž”
object
An objectID must be specified for each record.
If the objectID exists, the record is replaced
If the objectID doesn’t exist, the engine will create a record
Parameter
Description
Response
This section shows the JSON response returned by the API.
Each API client encapsulates this response inside objects specific to the programming language,
so that the actual response might be different.
You can view the response by using the getLogs method.
Don’t rely on the order of attributes in the response, as JSON doesn’t guarantee the ordering of keys in objects.