Skip to content

DX-2963: add vector index commands and redis.vector namespace - #1446

Open
CahidArda wants to merge 1 commit into
mainfrom
DX-2963-vector-commands
Open

DX-2963: add vector index commands and redis.vector namespace#1446
CahidArda wants to merge 1 commit into
mainfrom
DX-2963-vector-commands

Conversation

@CahidArda

@CahidArda CahidArda commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the new VECTOR.* commands (RED-769 / RED-962) behind a redis.vector namespace that mirrors redis.search, plus raw commands under pipeline.vector.*.

Usage

// create (or attach to) an index
const index = await redis.vector.createIndex({ name: "docs", dimension: 3, metric: "COSINE", existsOk: true }); // metric: COSINE | EUCLIDEAN | DOT
const same = redis.vector.index("docs"); // no round trip

// add — number[] (VALUES), Float32Array (BASE64-FP32), or a base64 FP32 blob from an embedding API
await index.add("doc-1", [0.1, 0.2, 0.3]);                         // 1 = inserted, 0 = overwritten
await index.add("doc-2", new Float32Array([0.3, 0.2, 0.1]));
await index.add("doc-3", { base64: embedding.data[0].embedding }); // openai encoding_format: "base64"

// query
const hits = await index.query({ vector: [0.1, 0.2, 0.3], topK: 5 });      // [{ id: "doc-1", score: 1 }, ...]
await index.query({ vector: queryVec, topK: 10, profile: "PRECISE" });      // FAST | BALANCED (default) | PRECISE

// read / manage
await index.get("doc-1");   // [0.1, 0.2, 0.3] | null
await index.count();        // 3
await index.info();         // { dimension: 3, metric: "COSINE" } | null
await index.delete("doc-1"); // 1 | 0
await index.drop();         // 1 | 0

// pipeline / multi
const [created, added, n] = await redis.multi()
  .vector.create("docs", { dimension: 3, metric: "DOT" })
  .vector.add("docs", "a", [1, 0, 0])
  .vector.count("docs")
  .exec();

Changes

- VectorCreate/Add/Get/Query/Del/Count/Info/DropCommand in pkg/commands/vector_*.ts; types, FP32→base64 encoding, deserializers and VectorIndex in pkg/commands/vector/
- Query ids stay strings (default deserialization would turn "123" into 123); scores/values coerced to numbers; VECTOR.INFO's flat array mapped to { dimension, metric }
- "vector" added to the auto-pipeline EXCLUDE_COMMANDS: the namespace exists on both Redis and Pipeline, so the proxy otherwise resolved redis.vector to the pipeline's and createIndex was undefined
- VectorIndex + types exported from platforms/nodejs; minor changeset

Testing

41 new tests (per command, encoding/deserialization, VectorIndex, pipeline/multi, Redis-level incl. the auto-pipeline proxy) against a locally built redis-server (master @ 15e7e53)  the hosted test DB doesn't have VECTOR.* yet, so CI will fail on these until it's upgraded. Full suite against that server: 950 pass / 0 fail; tsc/eslint/prettier/tsup clean.

@linear-code

linear-code Bot commented Aug 26, 2026

Copy link
Copy Markdown

DX-2963

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant