$npx -y skills add redis/agent-skills --skill redis-searchRedis 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 lex
| 1 | # Redis Search |
| 2 | |
| 3 | 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. |
| 4 | |
| 5 | ## When to apply |
| 6 | |
| 7 | - Creating, modifying, or reviewing a Redis Search index (`FT.CREATE`, `FT.ALTER`). |
| 8 | - Writing or optimizing `FT.SEARCH`, `FT.AGGREGATE`, or `FT.HYBRID` queries. |
| 9 | - Picking between `TEXT`, `TAG`, `NUMERIC`, `GEO`, `GEOSHAPE`, `VECTOR`, or JSON-path fields. |
| 10 | - Defining a `VECTOR` field, choosing HNSW vs FLAT, tuning HNSW parameters. |
| 11 | - Building a retrieval-augmented generation (RAG) pipeline. |
| 12 | - Rolling out a new index schema without downtime. |
| 13 | - Troubleshooting empty results, slow queries, or tokenization issues with `FT.EXPLAIN`, `FT.PROFILE`, `FT.INFO`. |
| 14 | |
| 15 | ## 1. Pick the right command |
| 16 | |
| 17 | Three query commands. Reach for the narrowest one that fits. |
| 18 | |
| 19 | | Command | When to use | Mental model | Minimum Redis | |
| 20 | |---|---|---|---| |
| 21 | | **FT.SEARCH** | Document retrieval, ranked or sorted. Best default. | Returns matching docs directly. | 2.0 (module) / 8.0 (built-in) | |
| 22 | | **FT.AGGREGATE** | Faceting, computed fields, custom output shape, analytics. | Declarative pipeline: `LOAD`, `APPLY`, `GROUPBY`, `REDUCE`, `SORTBY`. | 2.0 / 8.0 | |
| 23 | | **FT.HYBRID** | Blend lexical (BM25) with vector similarity, with configurable fusion. | Pipeline with explicit `SEARCH` + `VSIM` legs and a `COMBINE` fusion stage. | **8.4.0** | |
| 24 | |
| 25 | ``` |
| 26 | # FT.SEARCH — most common |
| 27 | FT.SEARCH idx:products "@category:{electronics} @price:[100 500]" LIMIT 0 20 RETURN 3 name price category |
| 28 | |
| 29 | # FT.AGGREGATE — top categories by avg price |
| 30 | FT.AGGREGATE idx:products "*" GROUPBY 1 @category REDUCE AVG 1 @price AS avg_price SORTBY 2 @avg_price DESC |
| 31 | |
| 32 | # FT.HYBRID (Redis ≥ 8.4) — lexical + vector fusion |
| 33 | FT.HYBRID idx:docs |
| 34 | SEARCH "@title:transformers" SCORER BM25 YIELD_SCORE_AS lexscore |
| 35 | VSIM embedding $vec KNN count 1 K 50 YIELD_SCORE_AS vecscore |
| 36 | COMBINE RRF 2 CONSTANT 60 |
| 37 | PARAMS 2 vec "..." |
| 38 | DIALECT 2 |
| 39 | ``` |
| 40 | |
| 41 | For Redis < 8.4 the lexical+vector blend is approximated with `FT.SEARCH` pre-filter + `=>[KNN ...]`. See [references/command-selection.md](references/command-selection.md) and [references/hybrid-search.md](references/hybrid-search.md). |
| 42 | |
| 43 | ## 2. Schema basics — `FT.CREATE` |
| 44 | |
| 45 | `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). |
| 46 | |
| 47 | ``` |
| 48 | FT.CREATE idx:products ON HASH PREFIX 1 product: |
| 49 | SCHEMA |
| 50 | name TEXT WEIGHT 2.0 |
| 51 | category TAG SORTABLE |
| 52 | price NUMERIC SORTABLE |
| 53 | location GEO |
| 54 | embedding VECTOR HNSW 6 |
| 55 | TYPE FLOAT32 |
| 56 | DIM 1536 |
| 57 | DISTANCE_METRIC COSINE |
| 58 | ``` |
| 59 | |
| 60 | Pick the narrowest field type that supports your access pattern: |
| 61 | |
| 62 | | Field type | Use when | Notes | |
| 63 | |---|---|---| |
| 64 | | `TEXT` | Full-text search | Tokenized + stemmed; **not** for exact match | |
| 65 | | `TAG` | Exact match / filtering | Add `SORTABLE UNF` for fastest tag queries | |
| 66 | | `NUMERIC` | Range queries, sorting | Prices, counts, timestamps | |
| 67 | | `GEO` | Lat/long points | Stores, users | |
| 68 | | `GEOSHAPE` | Polygon / area queries | Delivery zones, regions | |
| 69 | | `VECTOR` | Similarity search | HNSW or FLAT; see §4 | |
| 70 | | JSON `$.path AS alias` | Nested JSON fields | `ON JSON`; see [references/json-indexing.md](references/json-indexing.md) | |
| 71 | |
| 72 | 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. |
| 73 | |
| 74 | See [references/index-creation.md](references/index-creation.md), [references/field-types.md](references/field-types.md), [references/dialect.md](references/dialect.md), [references/ft-create-options.md](references/ft-create-options.md), [references/json-indexing.md](references/json-indexing.md). |
| 75 | |
| 76 | ## 3. Common queries |
| 77 | |
| 78 | Narrow with filters; return only what you need. |
| 79 | |
| 80 | ``` |
| 81 | # Tag filter + numeric range, sorted by price |
| 82 | FT.SEARCH idx:products "@category:{electronics} @price:[100 500]" |
| 83 | SORTBY price ASC |
| 84 | LIMIT 0 20 |
| 85 | RETURN 3 name price category |
| 86 | |
| 87 | # Text + tag filter |
| 88 | FT.SEARCH idx:products "wireless headphones @ |