This is documentation for v3 of the PHP API clients, which is not the latest version.
To see the documentation for the latest version, see
PHP v4.
This is documentation for v2 of the Ruby API clients, which is not the latest version.
To see the documentation for the latest version, see
Ruby v3.
This is documentation for v4 of the JavaScript API clients, which is not the latest version.
To see the documentation for the latest version, see
JavaScript v5.
This is documentation for v3 of the Python API clients, which is not the latest version.
To see the documentation for the latest version, see
Python v4.
This is documentation for v8 of the Swift API clients, which is not the latest version.
To see the documentation for the latest version, see
Swift v9.
This is documentation for v2 of the Kotlin API clients, which is not the latest version.
To see the documentation for the latest version, see
Kotlin v3.
This is documentation for v6 of the C# API clients, which is not the latest version.
To see the documentation for the latest version, see
C# v7.
This is documentation for v3 of the Java API clients, which is not the latest version.
To see the documentation for the latest version, see
Java v4.
This is documentation for v3 of the Go API clients, which is not the latest version.
To see the documentation for the latest version, see
Go v4.
This is documentation for v1 of the Scala API clients, which is not the latest version.
To see the documentation for the latest version, see
Scala v2.
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
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.
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)
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.