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

# SEARCH.ALIASADD

> Create or update a search index alias.

Use `SEARCH.ALIASADD` to create an alias or update an existing alias to point to a search index.

An alias is a stable name that queries can use in place of a real index name, so the index behind it can be replaced without touching application code. Pointing an existing alias at a different index is atomic, which is what makes zero-downtime reindexing possible: build the new index under a fresh name, then move the alias to it in one step.

See [Aliases](/docs/redis/search/aliases#adding-an-alias) for feature examples, including zero-downtime index swaps.

The target name is not required to exist when the alias is created, so aliases can temporarily be dangling. Most commands resolve aliases, but [`SEARCH.DROP`](/docs/redis/commands/search/search-drop) always uses a literal index name.

## Syntax

```redis theme={"system"}
SEARCH.ALIASADD <alias> <index_name>
```

## Response

Returns `1` if a new alias was created or `2` if an existing alias was updated, including when it already points to the supplied index.

## Examples

<AccordionGroup>
  <Accordion title="Redis CLI" icon="terminal">
    ```bash theme={"system"}
    SEARCH.ALIASADD products products-v2
    ```
  </Accordion>

  <Accordion title="@upstash/redis" icon="node-js" iconType="brands">
    ```ts theme={"system"}
    import { Redis } from "@upstash/redis";

    const redis = Redis.fromEnv();
    const result = await redis.search.alias.add({
      alias: "products",
      indexName: "products-v2",
    });
    ```
  </Accordion>

  <Accordion title="upstash_redis" icon="python" iconType="brands">
    ```python theme={"system"}
    from upstash_redis import Redis

    redis = Redis.from_env()
    result = redis.search.alias.add(
        alias="products",
        index_name="products-v2",
    )
    ```
  </Accordion>

  <Accordion title="ioredis" icon="node-js" iconType="brands">
    ```ts theme={"system"}
    import IORedis from "ioredis";
    import { createSearch } from "@upstash/search-ioredis";

    const redis = new IORedis(process.env.REDIS_URL!);
    const search = createSearch(redis);
    const result = await search.alias.add({
      alias: "products",
      indexName: "products-v2",
    });
    ```
  </Accordion>

  <Accordion title="node-redis" icon="node-js" iconType="brands">
    ```ts theme={"system"}
    import { createClient } from "redis";
    import { createSearch } from "@upstash/search-redis";

    const client = await createClient({ url: process.env.REDIS_URL })
      .on("error", console.error)
      .connect();
    const search = createSearch(client);
    const result = await search.alias.add({
      alias: "products",
      indexName: "products-v2",
    });
    ```
  </Accordion>

  <Accordion title="curl">
    ```bash theme={"system"}
    curl -X POST https://YOUR_ENDPOINT.upstash.io \
      -H "Authorization: Bearer $UPSTASH_REDIS_REST_TOKEN" \
      -d '["SEARCH.ALIASADD", "products", "products-v2"]'
    ```
  </Accordion>
</AccordionGroup>


## Related topics

- [Aliases](/docs/redis/search/aliases.md)
- [Changelog](/docs/redis/overall/changelog.md)
- [Search](/docs/search/sdks/ts/commands/search.md)
- [Search commands](/docs/redis/commands/search/overview.md)
