Documentation

Indexing and Querying

Introduction#

Conceptually, Redis is based on the key-value database paradigm. Every piece of data is associated with a key, either directly or indirectly. If you want to retrieve data based on anything besides the key, you’ll need to implement an index that leverages one of the many data types available in Redis.

You have various ways to create index using Redis core datastructures, for example:

  • Sorted sets to create secondary indexes by ID or other numerical fields.
  • Sorted sets with lexicographical ranges for creating more advanced secondary indexes, composite indexes and graph traversal indexes.
  • Sets for creating random indexes.
  • Lists for creating simple iterable indexes and last N items indexes.

When using these datastructures you must create your own API to keep the index up-to-date. To simplify and automate this task, Redis has Search that allows indexing and querying.

The easiest way to index and query data in Redis is to use the Redis Search module.

You can follow the Redis Search Tutorial to learn more about it and look at the following video from Redis University:

If you have questions about Redis Search and other module ask them in the Redis Community Forum.