RediSearch adds a real secondary-index engine to Redis — a write-time index over Hash or JSON keys, full-text query, numeric range filters, geo queries, vector similarity, and aggregations. It is the difference between scanning a million keys with KEYS (don’t) and serving a typed FT.SEARCH in milliseconds. This article covers the index lifecycle, the query syntax operators actually use, and the cost model of running RediSearch in production.
How to verify
# Confirm the module is loaded
redis-cli MODULE LIST | grep -i search
# Expected: search or ReDiSearch
# Inspect an existing index
redis-cli FT._LIST
redis-cli FT.INFO idx:products
redis-cli FT.PROFILE idx:products SEARCH QUERY '@brand:{nike}'
What’s happening
An index in RediSearch is a declarative description: “for every key matching product:*, index these fields with these types”. When you write a document, the module updates the index synchronously — the cost of an HSET or JSON.SET includes index maintenance. When you query, the engine walks an inverted index for text terms, a numeric tree for ranges, and a geo index for distance, returning matching keys plus optional projected fields.
Index fields have types:
TEXT— tokenized, stemmed, full-text searchable.NUMERIC— range queries[10 100].TAG— exact-match enumerated values, useful forcategory,state,country.GEO—lon,latforGEOFILTERqueries.VECTOR— dense vector similarity (HNSW or FLAT), used for embeddings.
RediSearch is not Elasticsearch — it does not have node-level sharding outside Redis Enterprise, and a single OSS index lives on a single Redis instance. On a Redis Cluster, an index is per-shard; the same index name on every shard, and the application is responsible for fanning out and merging if it needs cluster-wide results. Redis Stack and Redis Enterprise handle this transparently; OSS Cluster does not.
The dominant operational cost is index size: an index typically uses 20-100% of the size of the source data, depending on field types. A high-cardinality TEXT index over million-row documents can outweigh the data itself.
The procedure
-
Confirm the module is loaded. Redis Stack ships it; for OSS Redis, add to
redis.conf:loadmodule /usr/lib/redis/modules/redisearch.so -
Create an index over Hash documents. This indexes every key matching
product:*.redis-cli FT.CREATE idx:products \ ON HASH PREFIX 1 product: \ SCHEMA \ name TEXT SORTABLE WEIGHT 2.0 \ description TEXT \ brand TAG SORTABLE \ price NUMERIC SORTABLE \ location GEO -
Load some documents.
redis-cli HSET product:1 name "Air Max 95" brand nike price 180 \ location "-79.38,43.65" description "Retro running shoe" redis-cli HSET product:2 name "Yeezy Boost 350" brand adidas price 250 \ location "-79.39,43.66" description "Boost foam runner" -
Search by text, tag, and range.
redis-cli FT.SEARCH idx:products '@brand:{nike} @price:[100 200]' redis-cli FT.SEARCH idx:products 'running' RETURN 2 name price redis-cli FT.SEARCH idx:products \ '@location:[-79.39 43.65 5 km]' LIMIT 0 10 -
Aggregate. Group by brand and average price.
redis-cli FT.AGGREGATE idx:products '*' \ GROUPBY 1 @brand \ REDUCE AVG 1 @price AS avg_price \ SORTBY 2 @avg_price DESC -
Profile a query to see term-expansion, doc-scan count, and timing:
redis-cli FT.PROFILE idx:products SEARCH QUERY 'running shoe' LIMITED -
Drop and recreate when the schema changes. RediSearch does not support online ALTER of all fields; for TEXT additions
FT.ALTERis available, for type changes you mustFT.DROPINDEXandFT.CREATE.
Common pitfalls
- An index on a high-write-rate key set adds latency to every write. Watch
INFO commandstatsandFT.INFOfortotal_indexing_timeandindexing_failures. - A document not appearing in queries usually means the prefix in
FT.CREATEdoes not match the key (product:vsproducts:). CheckFT.INFO idx:productsfornum_docs. FT.SEARCHwithoutLIMITreturns the first 10 results by default. Asking forLIMIT 0 100000blocks the server while serializing — paginate, or useFT.AGGREGATEwith cursors.- TAG values are case-sensitive and tokenized only by the
SEPARATORargument.{Nike}does not match{nike}unless you index withCASESENSITIVEoff (the default) and store lowercase. - An index does not survive
FLUSHDB— but the keys do, leaving an orphan index missing documents. AlwaysFT.DROPINDEXfirst, or rebuild the index after a flush.
In the engagements we run, RediSearch shows up most often as the query layer behind product catalogs, customer-360 dashboards, and recently RAG vector retrieval. We operate Redis Stack and Enterprise under Managed Operations — index sizing, write-rate budgeting and index-aware backups are part of the runbook. Pair it with RedisJSON when the documents are nested rather than flat hashes.