Generated banner for Redis Search
Generated logo for Redis Search

Redis Search

RedisOfficialCreated by Redis, Inc.

  • Skill
  • Tool integration
  • Data and AI
  • MIT
  • No issues found

From the author

Redis Search guidance covering FT.CREATE schema design, field type selection (TEXT, TAG, NUMERIC, GEO, GEOSHAPE, VECTOR, JSON path), DIALECT 2 query syntax, FT.SEARCH / FT.AGGREGATE / FT.HYBRID command selection, vector similarity with HNSW or FLAT, hybrid retrieval combining lexical and vector ranking, RAG pipelines, zero-downtime index updates via aliases, and debugging with FT.PROFILE and FT.EXPLAIN. Use when defining a search index on Hash or JSON documents, writing FT.SEARCH queries with filters, sorting, aggregation, or vector KNN, tuning HNSW parameters, building a RAG retrieval pipeline, or troubleshooting slow or empty search results.
— the description by Redis, Inc.

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a centralized reference for Redis Search, covering the full lifecycle of index management and query execution. It details schema design using FT.CREATE, command selection between FT.SEARCH, FT.AGGREGATE, and FT.HYBRID, and advanced techniques like vector similarity search (HNSW/FLAT) and RAG pipeline integration. It also includes operational best practices for zero-downtime index updates and performance debugging using FT.PROFILE and FT.EXPLAIN.

What it does

  • Guides schema design for Hash and JSON documents using various field types.
  • Explains command selection for lexical, vector, and hybrid search requirements.
  • Provides patterns for vector similarity search, including HNSW and FLAT algorithm tuning.
  • Details the construction of declarative aggregation pipelines for analytics.
  • Offers strategies for zero-downtime index management and schema evolution.
  • Assists in troubleshooting performance and query results with profiling tools.

When to use it

  • When defining or modifying a search index schema for Redis.
  • When building retrieval-augmented generation (RAG) pipelines.
  • When optimizing complex search queries or aggregation pipelines.
  • When troubleshooting slow queries or unexpected search results.
  • When implementing vector similarity search for machine learning applications.

Advantages

  • Consolidates complex search and vector indexing patterns into a single reference.
  • Provides clear guidance on choosing the most efficient query command.
  • Includes practical examples for common search and aggregation scenarios.
  • Offers actionable advice for performance tuning and debugging.
  • Supports modern development workflows like RAG and zero-downtime updates.

Usage examples

“How do I create a search index for JSON documents with a vector field?”
The agent provides the FT.CREATE syntax, specifying the ON JSON option, the correct prefix, and the schema definition including the VECTOR field with appropriate DIM and DISTANCE_METRIC settings.
“My vector search is slow. How can I optimize it?”
The agent suggests using FT.PROFILE to identify bottlenecks, checking HNSW parameters like M and EF_RUNTIME, and ensuring the query uses appropriate pre-filters to narrow the search space.
“How do I perform a hybrid search combining text and vector similarity?”
The agent explains the use of FT.HYBRID (for Redis 8.4+) or the pre-filter pattern for earlier versions, detailing how to blend scores using RRF or linear fusion.
“How can I update my index schema without taking the application offline?”
The agent outlines the alias pattern: creating a new index version, populating it, and then using FT.ALIASUPDATE to point the application to the new index seamlessly.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/redis/redis-search/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip redis-search.zip -d .agents/skills

Documentation by Redis, Inc.

Single source of guidance for Redis Search — the retrieval surface that spans lexical, numeric, geo, JSON-path, and vector queries. Vector fields are part of the same FT.CREATE machinery as TEXT/TAG/NUMERIC fields, and FT.HYBRID blends lexical and vector ranking in one command, so this skill covers them together.

When to apply

  • Creating, modifying, or reviewing a Redis Search index (FT.CREATE, FT.ALTER).

  • Writing or optimizing FT.SEARCH, FT.AGGREGATE, or FT.HYBRID queries.

  • Picking between TEXT, TAG, NUMERIC, GEO, GEOSHAPE, VECTOR, or JSON-path fields.

  • Defining a VECTOR field, choosing HNSW vs FLAT, tuning HNSW parameters.

  • Building a retrieval-augmented generation (RAG) pipeline.

  • Rolling out a new index schema without downtime.

  • Troubleshooting empty results, slow queries, or tokenization issues with FT.EXPLAIN, FT.PROFILE, FT.INFO.

1. Pick the right command

Three query commands. Reach for the narrowest one that fits.

CommandWhen to useMental modelMinimum Redis
FT.SEARCHDocument retrieval, ranked or sorted. Best default.Returns matching docs directly.2.0 (module) / 8.0 (built-in)
FT.AGGREGATEFaceting, computed fields, custom output shape, analytics.Declarative pipeline: LOAD, APPLY, GROUPBY, REDUCE, SORTBY.2.0 / 8.0
FT.HYBRIDBlend lexical (BM25) with vector similarity, with configurable fusion.Pipeline with explicit SEARCH + VSIM legs and a COMBINE fusion stage.8.4.0
# FT.SEARCH — most common
FT.SEARCH idx:products "@category:{electronics} @price:[100 500]" LIMIT 0 20 RETURN 3 name price category

# FT.AGGREGATE — top categories by avg price
FT.AGGREGATE idx:products "*" GROUPBY 1 @category REDUCE AVG 1 @price AS avg_price SORTBY 2 @avg_price DESC

# FT.HYBRID (Redis ≥ 8.4) — lexical + vector fusion
FT.HYBRID idx:docs
  SEARCH "@title:transformers" SCORER BM25 YIELD_SCORE_AS lexscore
  VSIM embedding $vec KNN count 1 K 50 YIELD_SCORE_AS vecscore
  COMBINE RRF 2 CONSTANT 60
  PARAMS 2 vec "..."
  DIALECT 2

For Redis < 8.4 the lexical+vector blend is approximated with FT.SEARCH pre-filter + =>[KNN ...]. See references/command-selection.md and references/hybrid-search.md.

2. Schema basics — FT.CREATE

FT.CREATE indexes Hash or JSON documents matching a PREFIX. Always set PREFIX. Use DIALECT 2 (the default since Redis 8; required for vector queries).

FT.CREATE idx:products ON HASH PREFIX 1 product:
    SCHEMA
        name TEXT WEIGHT 2.0
        category TAG SORTABLE
        price NUMERIC SORTABLE
        location GEO
        embedding VECTOR HNSW 6
            TYPE FLOAT32
            DIM 1536
            DISTANCE_METRIC COSINE

Pick the narrowest field type that supports your access pattern:

Field typeUse whenNotes
TEXTFull-text searchTokenized + stemmed; not for exact match
TAGExact match / filteringAdd SORTABLE UNF for fastest tag queries
NUMERICRange queries, sortingPrices, counts, timestamps
GEOLat/long pointsStores, users
GEOSHAPEPolygon / area queriesDelivery zones, regions
VECTORSimilarity searchHNSW or FLAT; see §4
JSON $.path AS aliasNested JSON fieldsON JSON; see references/json-indexing.md

The classic mistake is TEXT for a category or status field "because it's a string" — TAG is roughly 10× faster for exact-match filtering.

See references/index-creation.md, references/field-types.md, references/dialect.md, references/ft-create-options.md, references/json-indexing.md.

3. Common queries

Narrow with filters; return only what you need.

# Tag filter + numeric range, sorted by price
FT.SEARCH idx:products "@category:{electronics} @price:[100 500]"
    SORTBY price ASC
    LIMIT 0 20
    RETURN 3 name price category

# Text + tag filter
FT.SEARCH idx:products "wireless headphones @category:{audio}"

# Negation and OR
FT.SEARCH idx:products "@category:{audio} -@brand:{generic} (@price:[0 100] | @on_sale:{true})"

Operators worth remembering: space = AND, | = OR, - = NOT, ~ = optional (scoring boost), =>{$weight: N} = boost. Escape hyphens and special characters inside TAG values (@sku:{ABC\\-123}). See references/query-syntax.md and references/search-syntax-primitives.md for the DSL vocabulary.

For tokenization gotchas (stemming, stopwords, language) see references/text-tokenization.md. For result shaping (SORTBY, RETURN, HIGHLIGHT, SUMMARIZE, NOCONTENT) see references/result-shaping.md. For performance levers (pre-filters, SORTABLE fields, tight RETURN, FT.PROFILE) see references/query-optimization.md.

4. Vector basics

Three vector settings have to match the embedding model exactly:

  • DIM — output dimensionality (e.g. 1536 for OpenAI text-embedding-3-small). Mismatch produces silent garbage.

  • DISTANCE_METRIC — COSINE for normalized text embeddings (common case), IP for unnormalized inner-product, L2 for raw Euclidean.

  • TYPE — usually FLOAT32. Use FLOAT16 or quantized variants only when memory is the binding constraint.

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

# Pure KNN query (top 5 by cosine similarity)
FT.SEARCH idx:docs "*=>[KNN 5 @embedding $vec AS score]"
    PARAMS 2 vec "..."
    SORTBY score
    DIALECT 2
AlgorithmSpeedAccuracyMemoryUse for
HNSWFast (approximate)~95%+ recall (tunable)HigherProduction: >10k vectors, latency-sensitive
FLATSlow (exact)100%LowerSmall corpora (<10k), exact-match required

HNSW tuning levers: M (16–64, connections per node), EF_CONSTRUCTION (100–500, build quality), EF_RUNTIME (query-time candidate list).

See references/vector-query.md, references/algorithm-choice.md.

5. Hybrid retrieval

Two distinct patterns get called "hybrid." Pick by intent.

Filter-then-vector (any Redis version) — apply attribute filters so the engine narrows the search space before the vector comparison.

FT.SEARCH idx:docs "(@category:{tech} @date:[2024 +inf])=>[KNN 10 @embedding $vec AS score]"
    PARAMS 2 vec "..."
    SORTBY score
    DIALECT 2

Lexical + vector fusion (Redis ≥ 8.4) — blend BM25 text scoring with vector similarity, fuse with RRF or LINEAR. Use FT.HYBRID (see §1).

Don't fetch a wide unfiltered result and filter client-side — slower and less accurate. See references/hybrid-search.md.

6. Aggregations and shaping

FT.AGGREGATE is the declarative result-shaping command. Build a pipeline of stages.

# Top 5 categories by total revenue
FT.AGGREGATE idx:orders "@status:{shipped}"
    LOAD 2 @category @amount
    GROUPBY 1 @category
        REDUCE SUM 1 @amount AS revenue
    SORTBY 2 @revenue DESC
    LIMIT 0 5

Common stages: LOAD, APPLY (computed fields), FILTER (post-query), GROUPBY + REDUCE (SUM, COUNT, AVG, FIRST_VALUE, TOLIST), SORTBY, LIMIT.

For long-running result sets use WITHCURSOR + FT.CURSOR READ to page server-side. See references/aggregate-pipeline.md and references/aggregate-cursors.md.

7. RAG pattern

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

Practical tips:

  • Match the metric to the embedding model (almost always COSINE for normalized text models).

  • Chunk long documents (200–500-token chunks usually beat indexing whole pages).

  • Batch inserts rather than one call per record.

  • Pre-filter with attributes (tenant, recency, document type) before the vector search — see §5.

  • Re-rank at the top of the funnel if precision matters more than recall.

See references/rag-pattern.md.

8. Operations

Zero-downtime schema changes: keep app queries pointed at an alias and swap the underlying index.

FT.CREATE idx:products_v2 ON HASH PREFIX 1 product: SCHEMA ...
FT.ALIASUPDATE products idx:products_v2
# App queries are stable:
FT.SEARCH products "@category:{electronics}"

Useful management commands: FT.INFO, FT.DROPINDEX, FT._LIST, FT.ALIASADD/UPDATE/DEL. See references/index-management.md.

Debug empty or slow queries with FT.EXPLAIN (shows how the query was parsed) and FT.PROFILE (shows execution stats). See references/debugging.md.

9. Client examples

Inline examples in this SKILL.md are CLI / RESP form — the wire protocol every client serializes to. For idiomatic snippets in a specific client:

Other clients (Lettuce, node-redis, go-redis, NRedisStack, .NET) translate the same CLI form; coverage is tracked as a follow-up.

References

Files

references/json-indexing.md

Index JSON Documents with JSONPath and Aliases

For JSON documents, the schema declares ON JSON and each field is a JSONPath plus an AS <alias>. The alias is what you query against (@alias:...) — without AS, Redis Search generates one from the path that is awkward to type and easy to typo. Array elements ($.tags[*]) and nested objects ($.address.city) work seamlessly.

Correct: Index a JSON Bicycle catalog: TEXT, TAG, NUMERIC, an array of TAGs, and a vector.

# Source documents
JSON.SET bicycle:0 $ '{
  "model": "Hyperion",
  "brand": "Velorim",
  "description": "Lightweight mountain bicycle for trail riding",
  "price": 1299,
  "condition": "new",
  "categories": ["mountain", "trail", "lightweight"],
  "store_location": "-122.4,37.7",
  "description_embeddings": [/* 1536 floats */]
}'

# Index — each path declared with AS <alias>, alias is what queries reference
FT.CREATE idx:bicycle ON JSON PREFIX 1 bicycle:
    SCHEMA
        $.model              AS model             TEXT  WEIGHT 2.0
        $.brand              AS brand             TAG
        $.description        AS description       TEXT
        $.price              AS price             NUMERIC SORTABLE
        $.condition          AS condition         TAG
        $.categories[*]      AS categories        TAG
        $.store_location     AS store_location    GEO
        $.description_embeddings AS description_embeddings VECTOR HNSW 6
            TYPE FLOAT32
            DIM 1536
            DISTANCE_METRIC COSINE

Query against the aliases, not the paths:

FT.SEARCH idx:bicycle "@brand:{Velorim} @categories:{mountain} @price:[100 1500]"
    DIALECT 2

JSONPath syntax that works inside FT.CREATE

PatternMeaningExample
$.fieldScalar at the top level.$.price AS price NUMERIC
$.nested.fieldScalar inside a nested object.$.address.city AS city TAG
$.array[*]Each element of an array as a TAG/TEXT value.$.tags[*] AS tags TAG
$.array[*].fieldA field from each object in an array.$.variants[*].sku AS skus TAG

Incorrect: Omitting AS (forces awkward generated aliases), trying to query the raw path, or pointing a vector field at a non-array JSON value.

# Bad: no AS — field is queryable as @"$.price" which is fragile and ugly.
FT.CREATE idx:bicycle ON JSON PREFIX 1 bicycle:
    SCHEMA
        $.price NUMERIC

# Bad: querying by JSON path instead of alias — wrong field identifier
FT.SEARCH idx:bicycle "@$.price:[100 500]"   # use @price:[100 500]

JSON + vector pairing

  • Embeddings must be stored as a JSON array of numbers.

  • TYPE FLOAT32 + DIM must match the embedding model exactly (e.g., 1536 for OpenAI text-embedding-3-small, 768 for many open-source models).

  • JSON.SET ... '[...]' '$.embedding' accepts the array; the indexer encodes to FLOAT32 on read.

Gotcha: an array path indexed as TAG makes every element a discrete tag. The same path indexed as TEXT would tokenize each element. For categorical filters, prefer TAG.

Schema attribute vs raw JSONPath — which alias do I reference?

The rule is symmetric: query by the schema attribute name, not the JSONPath. If the schema declared $.author AS author, queries use @author. If a JSONPath was not declared in the schema (or declared without AS), the field is not directly queryable — in FT.AGGREGATE you must LOAD <n> $.path AS Alias before referencing @Alias downstream, and in FT.SEARCH SORTBY @author requires author to be in the schema as SORTABLE.

# Schema-declared with AS alias — query by the alias
$.author AS author TEXT SORTABLE
→ FT.SEARCH idx:books "@author:Asimov" SORTBY author ASC DIALECT 2

# Not in schema — must LOAD it first, then reference the loaded alias
FT.AGGREGATE idx:books "*"
    LOAD 1 $.author AS Author
    GROUPBY 1 @Author REDUCE COUNT 0 AS n
    DIALECT 2

Client mirrors

# redis-py — STEP_START json_indexing
# Mirrors doctests/home_json.py + dt_json.py
from redis import Redis
from redis.commands.search.field import TextField, TagField, NumericField, VectorField
from redis.commands.search.indexDefinition import IndexDefinition, IndexType

r = Redis()
schema = (
    TextField("$.model", as_name="model", weight=2.0),
    TagField("$.brand", as_name="brand"),
    TextField("$.description", as_name="description"),
    NumericField("$.price", as_name="price", sortable=True),
    TagField("$.categories[*]", as_name="categories"),
    VectorField("$.description_embeddings", as_name="description_embeddings",
                algorithm="HNSW",
                attributes={"TYPE": "FLOAT32", "DIM": 1536, "DISTANCE_METRIC": "COSINE"}),
)
r.ft("idx:bicycle").create_index(schema, definition=IndexDefinition(prefix=["bicycle:"], index_type=IndexType.JSON))
# STEP_END
// Jedis — STEP_START json_indexing
// Mirrors JsonExample.java + HomeJsonExample.java
import redis.clients.jedis.UnifiedJedis;
import redis.clients.jedis.search.FTCreateParams;
import redis.clients.jedis.search.IndexDataType;
import redis.clients.jedis.search.schemafields.*;

try (UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379")) {
    jedis.ftCreate("idx:bicycle",
        FTCreateParams.createParams().on(IndexDataType.JSON).prefix("bicycle:"),
        TextField.of("$.model").as("model").weight(2.0),
        TagField.of("$.brand").as("brand"),
        TextField.of("$.description").as("description"),
        NumericField.of("$.price").as("price").sortable(),
        TagField.of("$.categories[*]").as("categories"));
}
// STEP_END

Upstream sources

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Python, Needs Node.js

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
Redis, Inc.
Publisher
Redis (Official)
Source
redis/agent-skills · skills/redis-search · commit 74708da
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Also distributed in
redis/agent-skills

AutoGineer is not affiliated with or endorsed by Redis, Inc. or Redis.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download redis-search.zip