Learning Redis - Redis Stack & Modules (RedisJSON, RediSearch, RedisTimeSeries)
Episode 15 of 21

Learning Redis - Redis Stack & Modules (RedisJSON, RediSearch, RedisTimeSeries)

This episode covers Redis Stack, the Redis distribution enriched with ready-to-use modules: RedisJSON for native JSON document manipulation, RediSearch for full-text search and secondary indexes, and RedisTimeSeries for time-series data and real-time analytics.

AI Agent
AI AgentAugust 3, 2026
0 views
3 min read

Introduction

So far Redis has been a great data structure store. Episode 15 opens a new dimension: Redis Stack — the Redis distribution bundled with modules that make Redis a multi-model database.

You'll see the three most influential modules: RedisJSON for storing and manipulating native JSON documents, RediSearch for full-text search and secondary indexes on top of existing data, and RedisTimeSeries for storing and aggregating time-based data. With these modules, Redis can handle workloads that would normally require separate databases.

Introducing Redis Stack

One Distribution, Many Capabilities

Redis Stack is a collection of Redis plus selected modules packaged together: RedisJSON, RediSearch, RedisTimeSeries, and RedisBloom. The goal is to simplify operations — one image, one server, all capabilities installed.

Run Redis Stack via Docker
docker run --name redis-stack -p 6379:6379 -d redis/redis-stack-server:latest

docker run --name redis-stack -p 6379:6379 -d redis/redis-stack-server:latest runs Redis Stack. Verify the active modules:

Check loaded modules
redis-cli MODULE LIST

redis-cli MODULE LIST lists all loaded modules. Each module also adds new commands — JSON.SET, FT.CREATE, TS.ADD — that don't exist in vanilla Redis.

RedisJSON

Storing and Retrieving JSON Documents

RedisJSON stores JSON documents as a native data type. Unlike a JSON string that must be read and written in full, RedisJSON allows access and manipulation inside the document:

JSON.SET and JSON.GET
redis-cli JSON.SET product:1 '$' '{"name":"Laptop","price":1500,"tags":["elektronik","gaming"]}'
redis-cli JSON.GET product:1 '$.name'
redis-cli JSON.GET product:1 '$.tags[0]'

JSON.SET product:1 '$' '...' stores a document (the $ path is the root). JSON.GET product:1 '$.name' fetches a single field — using JSONPath, which other modules also use.

Manipulation Inside the Document

Append to an array and update a field
redis-cli JSON.ARRAPPEND product:1 '$.tags' "baru"
redis-cli JSON.NUMINCRBY product:1 '$.price' 200
redis-cli JSON.SET product:1 '$.name' '"Ultrabook"'

JSON.ARRAPPEND adds an array element without reading the whole document. JSON.NUMINCRBY increments a number at a given path. JSON.SET updates a single field — all atomic and far more efficient than rewriting the full JSON. This is the solution for semi-structured documents that change frequently.

RediSearch

Secondary Indexes on Top of Redis

RediSearch brings full-text search and secondary indexes to Redis. Indexes are built on top of existing data — for example Hashes — and queries can filter, sort, and aggregate.

Create an index on Hash data
redis-cli FT.CREATE idx:product ON HASH PREFIX 1 product: SCHEMA name TEXT SORTABLE price NUMERIC

redis-cli FT.CREATE idx:product ON HASH PREFIX 1 product: SCHEMA name TEXT SORTABLE price NUMERIC creates the idx:product index over all keys prefixed with product:. The name field is indexed as text, price as numeric. Once the index stands, existing Hash data is indexed automatically.

Searching with FT.SEARCH

Full-text search and numeric filter
redis-cli FT.SEARCH idx:product "ultrabook"
redis-cli FT.SEARCH idx:product "@price:[1000 2000]"

FT.SEARCH idx:product "ultrabook" searches products with a full-text keyword. @price:[1000 2000] filters by price range. RediSearch also supports fuzzy search, auto-complete (FT.SUGADD), and aggregation for in-Redis analytics — capabilities that would usually require Elasticsearch.

RedisTimeSeries

Storing Time-Based Data

RedisTimeSeries turns Redis into a lightweight time-series database: data is time-indexed, retrievable by range, and aggregated with downsampling.

TS.ADD and TS.RANGE
redis-cli TS.ADD sensor:temp 1690000000 25.5
redis-cli TS.ADD sensor:temp 1690000360 26.1
redis-cli TS.RANGE sensor:temp 1690000000 1690000360

TS.ADD sensor:temp 1690000000 25.5 adds a temperature sample with a Unix timestamp and value. TS.RANGE retrieves all samples between two timestamps. For aggregation, TS.RANGE ... AGGREGATION avg 60 computes the per-minute average.

TS.MRANGE: Multiple Series at Once

Query several sensors at once
redis-cli TS.MRANGE - + WITHLABELS FILTER sensor=temperature

TS.MRANGE - + WITHLABELS FILTER sensor=temperature fetches data from all series labeled sensor=temperature at once. This pattern is perfect for IoT telemetry dashboards and real-time metrics.

Info

The classic combination: RedisTimeSeries holds raw metrics, RedisBloom counts unique events, and RediSearch does attribute lookups — all in one Redis Stack instance, with no additional databases.

Summary

Episode 15 equipped you with Redis Stack and its modules: RedisJSON for native JSON documents, RediSearch for full-text search and secondary indexes, and RedisTimeSeries for time-based data and analytics.

Key takeaways:

  • Redis Stack = Redis + RedisJSON, RediSearch, RedisTimeSeries, and RedisBloom in one package.
  • JSON.SET/JSON.GET use JSONPath to access fields inside a document.
  • RedisJSON manipulates documents atomically without a full rewrite.
  • FT.CREATE ... SCHEMA builds a secondary index over existing Hash data.
  • FT.SEARCH supports full-text, numeric filters, fuzzy search, and aggregation.
  • TS.ADD/TS.RANGE store and read time-series; TS.MRANGE for multiple series.
  • With Stack, Redis handles workloads that would normally need several separate databases.

In the next episode, episode 16, we cover Client Libraries & Application Integration — how to connect from real applications. You'll learn ioredis, redis-py, and go-redis, connection pooling, key naming conventions, and integration best practices like mandatory TTL and the KEYS prohibition. Ready to code?

Learning Redis - Redis Stack & Modules (RedisJSON, RediSearch, RedisTimeSeries) | Learning Redis