Backend Development 14 min read

Comprehensive Guide to RediSearch: Features, Installation, and Query Operations

RediSearch is a Redis module that provides full‑text search, secondary indexing, and query capabilities; this guide introduces its features, compares performance with Elasticsearch, details installation via source and Docker, and demonstrates index creation, document management, and advanced search queries with code examples.

Architecture Digest
Architecture Digest
Architecture Digest
Comprehensive Guide to RediSearch: Features, Installation, and Query Operations

Introduction

RediSearch is a Redis module that adds full‑text search, secondary indexing, and powerful query capabilities to Redis. It uses compressed inverted indexes for fast, memory‑efficient searching and supports phrase matching, fuzzy search, numeric filtering, and more.

Key Features

Document‑level multi‑field full‑text indexing

High‑performance incremental indexing

Customizable document sorting

Complex boolean queries with AND/NOT operators

Optional query clauses

Prefix search

Field weight support

Autocomplete suggestions with fuzzy prefixes

Exact phrase search

Stemming‑based query expansion for many languages

Custom functions for query expansion and scoring

Field‑restricted search

Numeric filters and ranges

Geospatial filtering using Redis geo commands

Unicode support (UTF‑8)

Full document or ID‑only retrieval

Document deletion, update, and index garbage collection

Partial and conditional document updates

Performance Comparison with Elasticsearch

Index building time: RediSearch 221 s vs Elasticsearch 349 s (58 % faster).

In a simulated multi‑tenant e‑commerce benchmark (50 K indexes, 250 M documents), RediSearch built all indexes in 201 s, while Elasticsearch crashed after 921 indexes.

Query throughput: RediSearch achieved 12.5 K ops/s versus Elasticsearch 3.1 K ops/s (≈4× faster); latency was slightly lower (8 ms vs 10 ms).

Installation

3.1 Source Installation

git clone https://github.com/RediSearch/RediSearch.git
cd RediSearch
make setup
make install

3.2 Docker Installation

docker run -p 6379:6379 redislabs/redisearch:latest

3.3 Verify Installation

127.0.0.1:0>module list
1) 1) 'name' 2) 'ReJSON' 3) 'ver' 4) '20007'
2) 1) 'name' 2) 'search' 3) 'ver' 4) '20209'

If the returned array contains "search" (or "ft" in older versions), the RediSearch module is loaded successfully.

Command‑Line Operations

1. Create Index

ft.create 'student' schema 'name' text weight 5.0 'sex' text 'desc' text 'class' tag
'OK'

Here, student is the index name, and fields name , sex , desc are defined as text or tag types. The weight attribute adjusts field importance.

2. Add Document

ft.add student 001 1.0 language 'chinese' fields name '张三' sex '男' desc '这是一个学生' class '一班'
'OK'

Document ID is 001 , score 1.0 . The language flag sets the analyzer to Chinese; queries must use English characters for field names.

3. Search Queries

3.1 Basic Search

FT.SEARCH student * SORTBY sex desc RETURN 3 name sex desc
1) '2'
2) '001'
3) 1) 'name' 2) '张三' 3) 'sex' 4) '男' 5) 'desc' 6) '这是一个学生'

3.2 Match Query

ft.search student '张三' limit 0 10 RETURN 3 name sex desc
1) '2'
2) '001'
3) 1) 'name' 2) '张三' 3) 'sex' 4) '男' 5) 'desc' 6) '这是一个学生'

3.3 Fuzzy / Prefix Search

ft.search student '李*' SORTBY sex desc RETURN 3 name sex desc
1) '1'
2) '003'
3) 1) 'name' 2) '李四' 3) 'sex' 4) '男' 5) 'desc' 6) '这是一个学生'

3.4 Field‑Specific Search

ft.search student '@phone:185* @name:豆豆'
1) '1'
2) 'doudou'
3) 1) 'name' 2) '豆豆' 3) 'jtzz' 4) '“检索”是很多产品中' 5) 'phone' 6) '18563717107'

4. Delete Operations

ft.del student 002
'1'
ft.drop student
'OK'

5. View Operations

FT._LIST
1) 'student1' 2) 'ttao' 3) 'idx' 4) 'student' ...
ft.get student 001
1) 'name' 2) '张三' 3) 'sex' 4) '男' 5) 'desc' 6) '这是一个学生' 7) 'class' 8) '一班'

6. Alias Management

FT.ALIASADD xs student
'OK'
FT.ALIASDEL xs
'OK'

Conclusion

RediSearch offers a lightweight, high‑performance full‑text search solution tightly integrated with Redis, outperforming Elasticsearch in index build time and query throughput for many workloads. Its rich command set enables creation, manipulation, and advanced querying of indexed documents directly from the Redis CLI or client libraries.

backendCLIDockerRedisFull-Text SearchRediSearchElasticsearch Comparison
Architecture Digest
Written by

Architecture Digest

Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.