RediSearch for Full-Text Search

The RediSearch module provides querying, secondary indexing, and full-text search features. Although it’s possible to use a combination of Redis data structures to build search capabilities, it will take significant time and effort to do that. It’s preferable to use a module such as RediSearch since it’s purpose built for indexing and search requirements.

Concepts of RediSearch

At a high-level, RediSearch uses schema, indexes, and a query syntax to store and search documents.

  • Schema: RediSearch schema define the fields and attributes that will be indexed. Multiple attribute types are supported such as text, numeric, geospatial, etc. We can also add tags and sorting capabilities.

  • Index: An index is created with the help of a schema and allows us to specify the document prefix, language, filter expression, etc.

  • Documents: In RediSearch, documents can either be a Redis hash or a JSON document created using the RedisJSON module commands. Once these documents are added, they’re indexed by RediSearch and are made available for querying.

  • Query syntax: Finally, a RediSearch syntax can be used to execute search operations on the indexed documents. This includes queries such as searching for all documents, a specific attribute, etc.

The redisearch-go client

The RediSearch module has client libraries in multiple programming languages. In this lesson, we’ll use the redisearch-go client, which internally uses the redigo client (discussed in a previous lesson).

Commands of RediSearch

To better understand how the RediSearch module works, let’s explore the commands associated with this data type.

Create index

Get hands-on with 1400+ tech skills courses.