List of methods
Use this method to add new records (objects) to an index or replace existing records with an updated set of attributes.
|Partial update objects||
Update one or more attributes of an existing object.
Delete objects from an index using their
|Replace all objects||
Replaces all records from your index with a new set of records.
Remove all objects matching a filter (including geo filters).
Clear the records of an index without affecting its settings.
Get one or more objects using their
Perform several indexing operations in one API call.
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 Java API client in public beta. Read the beta documentation for more information.
You don’t need to create an index explicitly. Algolia creates an index automatically the first time you add records to it. To configure your index, see the settings section. Records are schemaless, so you don’t need to define any schema to start indexing.
initIndex method doesn’t create a new index on Algolia’s servers.
It creates an index object you can interact with—for example, to add records.
Don’t use sensitive or personally identifiable information (PII) as your index name, including user’s names, IDs, or email addresses. Since index names appear in network requests, consider them as being publicly available.
The documentation uses the terms “object” and “record”. Although different in the field of computer science, within Algolia’s domain, they’re often the same. The preference, though, is for this terminology:
- Records are the items in an Algolia index
- “Objects” are things like JSON structures or instances of classes in programming languages.
The records in your index are schemaless: they can hold any number of fields with any definition and content.
The engine has no expectations of your data other than formatting aspects and the
Every record in an index requires a unique ID (the
objectID). You can create it yourself and send it when indexing. If you don’t send an
objectID, Algolia generates it for you.
You can use this identifier later with any method that needs to reference a specific record, such as
Add, update, and partially update records
saveObjectsmethod requires an
objectIDunless you set
partialUpdateObjectsmethod requires an
Singular and plural methods
All methods can be singular or plural.
- If singular (for example,
saveObject), the method accepts one record as a parameter
- If plural (for example,
saveObjects), the method accepts one or multiple records.
See the individual methods for more information about syntax and usage.
Indexing methods are asynchronous. When you call one of these methods, Algolia adds a new task to a queue: the task, not the method call, performs the desired action. Algolia usually completes the task within seconds or milliseconds. It depends on the queue: the new task must wait its turn if the queue has multiple pending tasks.
To help manage this asynchronous indexing, each method returns a unique
taskID which you can use with the
waitTask guarantees a job is finished before proceeding with new requests.
To ensure that multiple jobs run in the correct order, add them to a queue by:
- Calling an indexing method
- Calling another indexing method
- And so on.
waitTask ensures that the first indexing methods added to the queue will run before any subsequently added methods are processed.
You can use this behavior to manage dependencies. For example, deleting an index before creating a new index with the same name or clearing an index before adding new records.