/index-management
Create, inspect, and drop search indexes. Wait for indexing to complete after data changes. Indexes automatically track Redis keys matching a specified prefix.
How it fires
How this command gets triggered: by you, by Claude, or both.
- Fires itselfClaude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/index-management
Context preview
What this command does when you run it.
Create, inspect, and drop search indexes. Wait for indexing to complete after data changes. Indexes automatically track Redis keys matching a specified prefix.
Command definition
index-management.mdIndex Management
Overview
Create, inspect, and drop search indexes. Wait for indexing to complete after data changes. Indexes automatically track Redis keys matching a specified prefix.
Good For
- Creating indexes over existing or new Redis data
- Inspecting index schema and configuration
- Rebuilding or dropping indexes
- Ensuring data consistency after bulk writes
Examples
Create an Index
import { Redis, s } from "@upstash/redis";
const redis = Redis.fromEnv();
// JSON index with nested schema
const index = await redis.search.createIndex({
name: "products",
prefix: "product:",
dataType: "json",
schema: s.object({
name: s.string(),
price: s.number("F64"),
metadata: s.object({
brand: s.facet(),
tags: s.keyword(),
}),
}),
});
// Hash index (flat schema only)
const hashIndex = await redis.search.createIndex({
name: "sessions",
prefix: "session:",
dataType: "hash",
schema: {
userId: { type: "TEXT" as const },
lastActive: { type: "DATE" as const },
},
});Create with Options
const index = await redis.search.createIndex({
name: "articles",
prefix: ["article:", "post:"], // multiple prefixes
dataType: "json",
language: "english", // stemming language
skipInitialScan: false, // scan existing keys (default)
existsOk: true, // don't error if index already exists
schema: s.object({
title: s.string(),
body: s.string().noStem(),
publishedAt: s.date().fast(),
}),
});Get a Reference to an Existing Index
// If you already created the index and just need a reference
const index = redis.search.index({
name: "products",
schema: s.object({
name: s.string(),
price: s.number("F64"),
}),
});
// Without schema (untyped - no filter/select type safety)
const untypedIndex = redis.search.index({ name: "products" });Describe an Index
const description = await index.describe();
// {
// name: "products",
// dataType: "json",
// prefixes: ["product:"],
// language: "english",
// schema: { name: { type: "TEXT" }, price: { type: "F64", fast: true } }
// }
// Returns null if index doesn't exist
const missing = await redis.search.index({ name: "nonexistent" }).describe();
// nullWait for Indexing
// After inserting/updating/deleting data, wait for index to catch up
await redis.json.set("product:1", "$", { name: "Laptop", price: 999 });
await redis.json.set("product:2", "$", { name: "Mouse", price: 29 });
await redis.json.set("product:3", "$", { name: "Keyboard", price: 79 });
await index.waitIndexing(); // blocks until all pending docs are indexed
// Queries now reflect the latest data
const results = await index.query({ filter: { name: { $eq: "Laptop" } } });Drop an Index
const result = await index.drop();
// 1 if dropped, 0 if index didn't exist
Supported Languages
For stemming: `english`, `french`, `spanish`, `portuguese`, `italian`, `german`, `dutch`, `swedish`, `norwegian`, `danish`, `finnish`, `hungarian`, `russian`, `romanian`, `turkish`, `arabic`, `chinese`, `japanese`
Read more
Index Management
Overview
Create, inspect, and drop search indexes. Wait for indexing to complete after data changes. Indexes automatically track Redis keys matching a specified prefix.
Good For
- Creating indexes over existing or new Redis data
- Inspecting index schema and configuration
- Rebuilding or dropping indexes
- Ensuring data consistency after bulk writes
Examples
Create an Index
import { Redis, s } from "@upstash/redis";
const redis = Redis.fromEnv();
// JSON index with nested schema
const index = await redis.search.createIndex({
name: "products",
prefix: "product:",
dataType: "json",
schema: s.object({
name: s.string(),
price: s.number("F64"),
metadata: s.object({
brand: s.facet(),
tags: s.keyword(),
}),
}),
});
// Hash index (flat schema only)
const hashIndex = await redis.search.createIndex({
name: "sessions",
prefix: "session:",
dataType: "hash",
schema: {
userId: { type: "TEXT" as const },
lastActive: { type: "DATE" as const },
},
});Create with Options
const index = await redis.search.createIndex({
name: "articles",
prefix: ["article:", "post:"], // multiple prefixes
dataType: "json",
language: "english", // stemming language
skipInitialScan: false, // scan existing keys (default)
existsOk: true, // don't error if index already exists
schema: s.object({
title: s.string(),
body: s.string().noStem(),
publishedAt: s.date().fast(),
}),
});Get a Reference to an Existing Index
// If you already created the index and just need a reference
const index = redis.search.index({
name: "products",
schema: s.object({
name: s.string(),
price: s.number("F64"),
}),
});
// Without schema (untyped - no filter/select type safety)
const untypedIndex = redis.search.index({ name: "products" });Describe an Index
const description = await index.describe();
// {
// name: "products",
// dataType: "json",
// prefixes: ["product:"],
// language: "english",
// schema: { name: { type: "TEXT" }, price: { type: "F64", fast: true } }
// }
// Returns null if index doesn't exist
const missing = await redis.search.index({ name: "nonexistent" }).describe();
// nullWait for Indexing
// After inserting/updating/deleting data, wait for index to catch up
await redis.json.set("product:1", "$", { name: "Laptop", price: 999 });
await redis.json.set("product:2", "$", { name: "Mouse", price: 29 });
await redis.json.set("product:3", "$", { name: "Keyboard", price: 79 });
await index.waitIndexing(); // blocks until all pending docs are indexed
// Queries now reflect the latest data
const results = await index.query({ filter: { name: { $eq: "Laptop" } } });Drop an Index
const result = await index.drop(); // 1 if dropped, 0 if index didn't exist
Supported Languages
For stemming: `english`, `french`, `spanish`, `portuguese`, `italian`, `german`, `dutch`, `swedish`, `norwegian`, `danish`, `finnish`, `hungarian`, `russian`, `romanian`, `turkish`, `arabic`, `chinese`, `japanese`
@upstash/redis is an HTTP/REST based Redis client for typescript, built on top of Upstash REST API. This project is in GA Stage. The Upstash Professional Support fully covers this project. It receives regular updates, and bug fixes.
Repo: upstash/redis-js
Other commands on redis-js.
- /aggregating
Run analytics over indexed data using metric and bucket aggregations. Compute statistics, group documents, build histograms, and perform faceted navigation. Aggregations can be nested for multi-level analysis.
Open command - /aliases
Index aliases provide an indirection layer between your application and the actual index. You can point an alias to any index and swap it atomically, enabling zero-downtime reindexing.
Open command - /querying
Query documents from a search index using type-safe filters with support for pagination, sorting, field selection, scoring, and highlighting. Count matching documents efficiently without returning results.
Open command

