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

# Aliases

Aliases let you create alternative names for your search indices. This is useful for zero-downtime reindexing — you can build a new index, then atomically swap the alias to point to it.

***

### Adding an Alias

The `SEARCH.ALIASADD` command creates a new alias or updates an existing alias to point to a different index.

Returns `1` if a new alias was created, or `2` if an existing alias was updated to point to a new index.

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={"system"}
    // Top-level: create or update an alias
    const result = await redis.search.alias.add({
      indexName: "products-v2",
      alias: "products",
    });

    // Via index method
    const result2 = await index.addAlias({ alias: "products" });
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={"system"}
    # Top-level: create or update an alias
    result = redis.search.alias.add(index_name="products-v2", alias="products")

    # Via index method
    result = index.add_alias(alias="products")
    ```
  </Tab>

  <Tab title="Redis CLI">
    ```bash theme={"system"}
    # Create or update an alias
    SEARCH.ALIASADD products products-v2
    ```
  </Tab>
</Tabs>

A common pattern is to use aliases for zero-downtime reindexing:

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={"system"}
    // 1. Create a new index with updated schema
    const productsV2 = await redis.search.createIndex({
      name: "products-v2",
      dataType: "json",
      prefix: "product:",
      schema,
    });

    // 2. Wait for indexing to complete
    await productsV2.waitIndexing();

    // 3. Swap the alias to point to the new index
    await redis.search.alias.add({
      indexName: "products-v2",
      alias: "products",
    });

    // 4. Drop the old index
    const oldIndex = redis.search.index({ name: "products-v1" });
    await oldIndex.drop();
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={"system"}
    # 1. Create a new index with updated schema
    products_v2 = redis.search.create_index(
        name="products-v2",
        data_type="json",
        prefix="product:",
        schema=schema,
    )

    # 2. Wait for indexing to complete
    products_v2.wait_indexing()

    # 3. Swap the alias to point to the new index
    redis.search.alias.add(index_name="products-v2", alias="products")

    # 4. Drop the old index
    old_index = redis.search.index(name="products-v1")
    old_index.drop()
    ```
  </Tab>

  <Tab title="Redis CLI">
    ```bash theme={"system"}
    # 1. Create new index
    SEARCH.CREATE products-v2 ON JSON PREFIX 1 product: SCHEMA name TEXT price F64 FAST

    # 2. Wait for indexing
    SEARCH.WAITINDEXING products-v2

    # 3. Swap alias
    SEARCH.ALIASADD products products-v2

    # 4. Drop old index
    SEARCH.DROP products-v1
    ```
  </Tab>
</Tabs>

***

### Deleting an Alias

The `SEARCH.ALIASDEL` command removes an alias.

Returns `1` if the alias was deleted, or `0` if the alias was not found.

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={"system"}
    const result = await redis.search.alias.delete({ alias: "products" });
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={"system"}
    result = redis.search.alias.delete(alias="products")
    ```
  </Tab>

  <Tab title="Redis CLI">
    ```bash theme={"system"}
    SEARCH.ALIASDEL products
    ```
  </Tab>
</Tabs>

***

### Listing Aliases

The `SEARCH.LISTALIASES` command returns all aliases and the indices they point to.

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={"system"}
    const aliases = await redis.search.alias.list();
    // → { "products": "products-v2", "users": "users-v1" }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={"system"}
    aliases = redis.search.alias.list()
    # → {"products": "products-v2", "users": "users-v1"}
    ```
  </Tab>

  <Tab title="Redis CLI">
    ```bash theme={"system"}
    SEARCH.LISTALIASES
    # → [["products", "products-v2"], ["users", "users-v1"]]
    ```
  </Tab>
</Tabs>
