> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Index operations are asynchronous

> Understand that all indexing operations are asynchronous and learn how to wait for a task to finish.

export const Records = () => <Tooltip tip="A record is a searchable object in an Algolia index. Each record consists of named attributes." cta="Algolia records" href="/doc/guides/sending-and-managing-data/prepare-your-data#algolia-records">
    records
  </Tooltip>;

export const Index = () => <Tooltip tip="An Algolia index is a searchable dataset that consists of records and configuration settings. These settings define how the records are searched and ranked.">
    index
  </Tooltip>;

**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`](/doc/libraries/sdk/v1/methods/wait-task) 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 <Index /> before creating a new one with the same name or clearing an index before adding new <Records />.
* **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`](/doc/libraries/sdk/v1/methods/replace-all-objects) 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`](/doc/libraries/sdk/v1/methods/wait-task) 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.
