Indexing API client methods

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.

List of methods

Indices

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.

The 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.

Records

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.

Schema

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 objectID.

The objectID

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 saveObjects or partialUpdateObjects.

Add, update, and partially update records

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.

Asynchronous methods

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 method. 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:

  1. Calling an indexing method
  2. Calling waitTask
  3. Calling another indexing method
  4. Calling waitTask
  5. 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.

Did you find this page helpful?