Skip to main content
All indexing operations run asynchronously. When you call indexing methods, you add a new job to a queue. The job, not the method itself, performs the desired action. Jobs usually finish within seconds or even milliseconds but processing time depends on the queue length. When the queue has many pending tasks, the job waits its turn.

When to wait for tasks

To help manage asynchronous jobs, each method returns a unique taskId, which you can use with the waitTask method. This ensures the job completes before the next request runs. Some common scenarios where waitTask is useful include:
  • Managing dependencies: you want to use waitTask to manage dependencies, for example, when deleting an before creating a new one with the same name or clearing an index before adding new .
  • Atomic reindexing: atomic reindexing is a way to update all your records without any downtime, by populating a temporary index and replacing the destination index with it. You don’t need to implement this by yourself. Instead, you can use the replaceAllObjects method which does it all for you.
  • Frontend events: if you’re building a frontend interface that performs indexing operations, you may want to react to completed tasks. For example, you may want to display a success message when an indexing operation has completed, or refresh a page, or move on with some following, co-dependent operations, etc.
  • Debugging: use waitTask when testing a search immediately after updating an index.

When not to wait for tasks

In most scenarios, you don’t need to wait for tasks to complete before moving on with new ones. Using waitTask makes your indexing operations synchronous, which slows them down. Don’t use waitTask instead of your language’s native asynchronous features. Ensure that tasks are queued in order by using promises or callbacks.
Last modified on January 28, 2026