Book Image

Redis Stack for Application Modernization

By : Luigi Fugaro, Mirko Ortensi
1 (1)
Book Image

Redis Stack for Application Modernization

1 (1)
By: Luigi Fugaro, Mirko Ortensi

Overview of this book

In modern applications, efficiency in both operational and analytical aspects is paramount, demanding predictable performance across varied workloads. This book introduces you to Redis Stack, an extension of Redis and guides you through its broad data modeling capabilities. With practical examples of real-time queries and searches, you’ll explore Redis Stack’s new approach to providing a rich data modeling experience all within the same database server. You’ll learn how to model and search your data in the JSON and hash data types and work with features such as vector similarity search, which adds semantic search capabilities to your applications to search for similar texts, images, or audio files. The book also shows you how to use the probabilistic Bloom filters to efficiently resolve recurrent big data problems. As you uncover the strengths of Redis Stack as a data platform, you’ll explore use cases for managing database events and leveraging introduce stream processing features. Finally, you’ll see how Redis Stack seamlessly integrates into microservices architectures, completing the picture. By the end of this book, you’ll be equipped with best practices for administering and managing the server, ensuring scalability, high availability, data integrity, stored functions, and more.
Table of Contents (18 chapters)
1
Part 1: Introduction to Redis Stack
6
Part 2: Data Modeling
11
Part 3: From Development to Production

Indexing the embeddings

Now that we can generate a vector for the desired type of data using the corresponding ML model, we would like to index vectors for VSS. Here, we’ll introduce the VECTOR field type which, together with TEXT, TAG, NUMERIC, and GEO, complete the types of data that can be indexed by Redis Stack. Using redis-cli to create an index as usual, we can index the embedding as follows:

FT.CREATE doc_idx
ON HASH
PREFIX 1 doc:
SCHEMA content AS content TEXT
genre AS genre TAG
embedding VECTOR HNSW 6 TYPE FLOAT32 DIM 384 DISTANCE_METRIC COSINE

We can index the JSON document in a similar fashion:

FT.CREATE doc_idx
ON JSON
PREFIX 1 doc:
SCHEMA $.content as content TEXT
$.genre AS genre TAG
$.embedding VECTOR HNSW 6 TYPE FLOAT32 DIM 384 DISTANCE_METRIC COSINE

This index includes the content of the document and the embedding and uses the related types: TEXT and VECTOR. In the next subsections, we will explain the meaning of the arguments for the vector similarity...