RediSearch Overview: Features, Benchmarks, Installation, and Command‑Line Operations
This article introduces RediSearch—a Redis module for full‑text search—detailing its features, performance comparison with Elasticsearch, index‑building and query benchmarks, installation methods (source and Docker), and comprehensive command‑line examples for creating, querying, updating, and managing indexes.
1. Introduction
RediSearch is a Redis module that adds query, secondary indexing and full‑text search capabilities to Redis. Users first declare an index on Redis data and then query it using the RediSearch query language.
It uses compressed inverted indexes for fast indexing with low memory consumption and provides features such as exact phrase matching, fuzzy search and numeric filtering.
2. Features
Document‑level multi‑field full‑text indexing
High‑performance incremental indexing
Custom document sorting (provided manually at index time)
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)
Retrieve full document or only IDs
Document deletion, update and index garbage collection
Partial updates and conditional document updates
3. Comparison with Elasticsearch
In the benchmark shown, RediSearch builds the index in 221 seconds while Elasticsearch takes 349 seconds, a 58 % speed improvement.
4. Index Build Test
A multi‑tenant e‑commerce scenario was simulated with 50 K indexes (each representing a product category) holding up to 500 documents each, for a total of 25 million documents.
RediSearch built all indexes in 201 seconds (≈125 K indexes per second). Elasticsearch crashed after 921 indexes, indicating it is not designed for this load.
5. Query Performance Test
After indexing, 32 client threads issued two‑word search queries. RediSearch achieved a throughput of 12.5 K ops/s, whereas Elasticsearch reached only 3.1 K ops/s – a four‑fold increase.
Latency was also slightly better: 8 ms average for RediSearch versus 10 ms for Elasticsearch.
6. Installation
Source installation
git clone https://github.com/RediSearch/RediSearch.git
cd RediSearch # enter module directory
make setup
make installDocker installation
Because the source package is difficult to compile, Docker is recommended.
docker run -p 6379:6379 redislabs/redisearch:latestVerify 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 “ft” or “search”, the RediSearch module is loaded successfully.
7. Command‑line Operations
7.1 Create Index
ft.create "student" schema "name" text weight 5.0 "sex" text "desc" text "class" tagThe index name (student) corresponds to a table name; fields are defined with their types. The optional weight defaults to 1.0.
7.2 Add Document
ft.add student 001 1.0 language "chinese" fields name "张三" sex "男" desc "这是一个学生" class "一班"Document ID is 001, score is 1.0. The language flag must be set to “chinese” for Chinese tokenisation.
7.3 Query
Full‑text query
FT.SEARCH student * SORTBY sex desc RETURN 3 name sex descMatch query
ft.search student "张三" limit 0 10 RETURN 3 name sex descPostfix fuzzy query
ft.search student "李*" SORTBY sex desc RETURN 3 name sex descLevenshtein fuzzy query
FT.SEARCH idx "%%张店%%"Uses Levenshtein distance (max 3) for approximate matching.
7.4 Delete
ft.del student 0027.5 Drop Index
ft.drop student7.6 View Indexes and Documents
FT._LIST
ft.get student 001
ft.mget student 001 0027.7 Alias Operations
FT.ALIASADD xs student
FT.ALIASDEL xsAn alias allows multiple names to refer to the same index.
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.