Skip to main content

Build

Redis Vector Search

RedisOfficialCertified

We earn commissions when you shop through the links below.

Redis vector search guidance covering HNSW vs FLAT algorithm choice, vector index configuration (dims, distance metric, datatype), filtered hybrid search combining vector similarity with TAG or NUMERIC filters, and the RAG retrieval pattern with RedisVL. Use when defining a VECTOR field in FT.CREATE, integrating embeddings (OpenAI, Cohere, sentence-transformers), tuning HNSW parameters (M, EF_CONSTRUCTION, EF_RUNTIME), building a retrieval-augmented generation pipeline, or filtering vector results by attribute.

  • 2 installs
  • v1.0.0
  • Reviewed Jul 21
  • No reviews yet

Capabilities

  • When to apply

    This skill builds on the redis-query-engine skill — vector fields live…

  • Configure the vector index properly

    See references/index-creation.md for redis-py and RedisVL variants

  • HNSW vs FLAT

    Default to HNSW for any production-scale workload

  • Hybrid search — filter before vector

    Apply attribute filters (TAG / NUMERIC) so the engine narrows the…

Getting started

Full instructions

Install the skill, then ask your AI tool for the task in plain words. The full SKILL.md below shows what it covers.

Instructions: SKILL.mdv1.0.0

Redis Vector Search

Guidance for storing and searching embeddings in Redis. Covers index configuration, algorithm selection, hybrid filtering, and the RAG retrieval pattern with RedisVL.

When to apply

  • Defining a VECTOR field in FT.CREATE (raw RQE) or a RedisVL IndexSchema.
  • Choosing HNSW vs FLAT and tuning HNSW parameters.
  • Adding category, date, or tenant filters to a vector query.
  • Building a retrieval-augmented generation (RAG) pipeline on top of Redis.

This skill builds on the redis-query-engine skill — vector fields live inside RQE indexes and share the same FT.CREATE / FT.SEARCH machinery.

1. Configure the vector index properly

Three settings must match the embedding model:

  • DIM — the model's output dimensionality (e.g. 1536 for OpenAI text-embedding-3-small). A mismatch produces silent garbage.
  • DISTANCE_METRIC — COSINE for normalized text embeddings (the common case), IP for unnormalized inner-product, L2 for raw Euclidean.
  • TYPE / datatype — usually FLOAT32. Use FLOAT16 or quantized variants only when memory cost is a hard constraint.

Raw RQE:

text
FT.CREATE idx:docs ON HASH PREFIX 1 doc:
    SCHEMA
        content TEXT
        embedding VECTOR HNSW 6
            TYPE FLOAT32
            DIM 1536
            DISTANCE_METRIC COSINE

RedisVL:

python
schema = IndexSchema.from_dict({
    "index": {"name": "idx:docs", "prefix": "doc:"},
    "fields": [
        {"name": "content", "type": "text"},
        {"name": "embedding", "type": "vector", "attrs": {
            "dims": 1536, "algorithm": "HNSW",
            "datatype": "FLOAT32", "distance_metric": "COSINE",
        }},
    ]
})

See references/index-creation.md for redis-py and RedisVL variants.

2. HNSW vs FLAT

Algorithm Speed Accuracy Memory Best for
HNSW Fast (approximate) ~95%+ recall (tunable) Higher Large datasets (>10k vectors), latency-sensitive
FLAT Slow (exact) 100% Lower Small datasets (<10k), accuracy-critical

Default to HNSW for any production-scale workload. Tuning levers:

  • M — connections per node (16–64). Higher = better recall, more memory.
  • EF_CONSTRUCTION — build-time graph quality (100–500). Higher = better index, slower build.
  • EF_RUNTIME — query-time candidate-list size. Higher = better recall, slower queries.

Use FLAT when the corpus is small and you need exact results (e.g. semantic dedup over a few thousand items).

See references/algorithm-choice.md.

3. Hybrid search — filter before vector

Apply attribute filters (TAG / NUMERIC) so the engine narrows the search space before the vector comparison. Don't fetch a wide result set and then filter client-side — that's slower and less accurate.

python
from redisvl.query import VectorQuery
from redisvl.query.filter import Num, Tag

filters = (Tag("category") == "technology") & (Num("date") >= 2024)

query = VectorQuery(
    vector=query_embedding,
    vector_field_name="embedding",
    return_fields=["content", "category", "date"],
    num_results=10,
    filter_expression=filters,
)
results = index.query(query)

For text + vector fusion (BM25-weighted text scoring combined with vector similarity), use HybridQuery on Redis ≥ 8.4 with redis-py ≥ 7.1, or AggregateHybridQuery on older Redis. That's a different "hybrid" from filtered vector search above.

See references/hybrid-search.md.

4. RAG pattern

Standard pipeline: embed the user query → vector search Redis → pass top-K context to the LLM.

python
# Index documents with embeddings
records = [{"content": doc.content,
            "embedding": embed_model.encode(doc.content).tolist(),
            "source": doc.source}
           for doc in documents]
index.load(records)

# Retrieve relevant context for a user question
q_emb = embed_model.encode(user_question)
results = index.query(VectorQuery(
    vector=q_emb,
    vector_field_name="embedding",
    return_fields=["content", "source"],
    num_results=5,
))

# Generate with retrieved context
context = "\n".join(r["content"] for r in results)
response = llm.generate(f"Context: {context}\n\nQuestion: {user_question}")

Practical tips:

  • Match metric to model. Most modern text embedding models pair best with COSINE.
  • Chunk long documents before indexing — retrieval over 200–500-token chunks usually beats indexing whole pages.
  • Batch inserts with index.load([...]) instead of one call per record.
  • Pre-filter with attributes (tenant, recency, document type) before the vector search.

See references/rag-pattern.md.

References

  • Redis: Vectors
  • Redis: RAG quickstart
  • RedisVL documentation
Browse all
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

View source →
redis-observabilityRedis observability guidance — which metrics to monitor (memory, connections, hit ratio, ops/sec, rejected connections), which built-in commands to reach for during incident triage (SLOWLOG, INFO, MEMORY DOCTOR, CLIENT LIST, FT.PROFILE),…2 installsredis-clusteringRedis Cluster and replication guidance covering hash tags for multi-key operations, avoiding CROSSSLOT errors, and reading from replicas to scale read-heavy workloads. Use when designing keys for a sharded Redis Cluster, debugging…2 installsredis-coreCore Redis modeling guidance — choose the right data structure (String, Hash, List, Set, Sorted Set, JSON, Stream, Vector Set) and use consistent colon-separated key names. Use when designing a Redis data model, caching objects, deciding…2 installsadd-redis-irisAdd Redis Iris to an existing AI agent in any framework (LangGraph, LangChain, OpenAI Agents SDK, Google ADK, Pydantic AI, CrewAI, or a plain loop). Use when the user asks to add Iris, Redis Agent Memory, Agent Playbooks, Context Gateway,…0 installsadd-agent-playbooksAdd Redis Iris Agent Playbooks to an existing agent. Use when approved answers or repeatable procedures live in prompts, document retrieval, or a semantic response cache. Connect or provision a Playbook, publish FAQs and Skills, and verify…0 installsredis-query-engineRedis Query Engine (RQE) guidance covering FT.CREATE schema design, field type selection (TEXT, TAG, NUMERIC, GEO, GEOSHAPE, VECTOR), DIALECT 2 query syntax, efficient FT.SEARCH and FT.AGGREGATE queries, zero-downtime index updates via…0 installs
What does the redis-vector-search skill do?

Redis vector search guidance covering HNSW vs FLAT algorithm choice, vector index configuration (dims, distance metric, datatype), filtered hybrid search combining vector similarity with TAG or NUMERIC filters, and the RAG retrieval pattern with RedisVL. Use when defining a VECTOR field in FT.CREATE, integrating embeddings (OpenAI, Cohere, sentence-transformers), tuning HNSW parameters (M, EF_CONSTRUCTION, EF_RUNTIME), building a retrieval-augmented generation pipeline, or filtering vector results by attribute. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the redis-vector-search skill?

Run `npx @skills-hub-ai/cli install redis-vector-search` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/redis-vector-search/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does redis-vector-search work with?

redis-vector-search runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the redis-vector-search skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use redis-vector-search after installing it?

In Claude Code, type `/redis-vector-search` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the redis-vector-search skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.

Badge for your README

Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.

Install on Skills Hub badge preview
Markdown
[![Install on Skills Hub](https://skills-hub.ai/api/badges/skill/redis-vector-search)](https://skills-hub.ai/skills/redis-vector-search)
HTML
<a href="https://skills-hub.ai/skills/redis-vector-search"><img src="https://skills-hub.ai/api/badges/skill/redis-vector-search" alt="Install on Skills Hub"></a>

More options in the badge docs.