Skip to content

RediSearch for secondary indexes and full-text search inside Redis

Define FT indexes over Hashes and JSON, query with full-text and numeric filters, and tune for write-rate vs query latency in a Redis Stack deployment.

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 for category, state, country.
  • GEO — lon,lat for GEOFILTER queries.
  • 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

  1. Confirm the module is loaded. Redis Stack ships it; for OSS Redis, add to redis.conf:

    loadmodule /usr/lib/redis/modules/redisearch.so
  2. 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
  3. 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"
  4. 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
  5. 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
  6. Profile a query to see term-expansion, doc-scan count, and timing:

    redis-cli FT.PROFILE idx:products SEARCH QUERY 'running shoe' LIMITED
  7. Drop and recreate when the schema changes. RediSearch does not support online ALTER of all fields; for TEXT additions FT.ALTER is available, for type changes you must FT.DROPINDEX and FT.CREATE.

Common pitfalls

  • An index on a high-write-rate key set adds latency to every write. Watch INFO commandstats and FT.INFO for total_indexing_time and indexing_failures.
  • A document not appearing in queries usually means the prefix in FT.CREATE does not match the key (product: vs products:). Check FT.INFO idx:products for num_docs.
  • FT.SEARCH without LIMIT returns the first 10 results by default. Asking for LIMIT 0 100000 blocks the server while serializing — paginate, or use FT.AGGREGATE with cursors.
  • TAG values are case-sensitive and tokenized only by the SEPARATOR argument. {Nike} does not match {nike} unless you index with CASESENSITIVE off (the default) and store lowercase.
  • An index does not survive FLUSHDB — but the keys do, leaving an orphan index missing documents. Always FT.DROPINDEX first, 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.