Skip to main content
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.
// 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" });
A common pattern is to use aliases for zero-downtime reindexing:
// 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();

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.
const result = await redis.search.alias.delete({ alias: "products" });

Listing Aliases

The SEARCH.LISTALIASES command returns all aliases and the indices they point to.
const aliases = await redis.search.alias.list();
// → { "products": "products-v2", "users": "users-v1" }