Indexing, Querying, and Full-Text Search of JSON Documents with Redis
Break the data matrix. Explore what Redis has to offer.
Do you remember RedisConf’s keynote demo? If yes, you might enjoy seeing the behind-the-curtain development of the retail application (RedisMart) that was presented. If not, then it’s time to watch Yiftach and Ash present it. Here’s the link to the video again:
This article is the first of a series. It gives you some insights into the main requirements and the architecture of the RedisMart retail application by looking at how you can implement a product catalog, a distributed real-time inventory, and an AI-powered product search. You’ll also see how Redis Enterprise powers all those functionalities.
As often in software development, let’s start by discussing some basic requirements. Here are some informally noted user stories:
Now that we know the requirements, let me draw an idea of how Redis is able to help us:
From there, it wasn’t too hard to imagine the following design:
The blue boxes represent services. The red boxes show the databases that are used by those services.
We followed some microservices approaches like:
RedisMart offers a user interface that’s served by the web-shop web application. RedisMart has a frontend UI (the customer-facing retail website) and a backend UI (for managing the inventory). We implemented a bunch of services that are leveraged by the application behind the scenes.
As mentioned before, this is the first article of a series. Please stay tuned to learn more about how we implemented the individual services.
Now that we’ve looked behind the curtain, let’s see how the application looks on stage.
The home page shows you the main product categories. A click on a category triggers a search query via the product catalog service by returning the first 16 products that belong to such a category.
The “Search products” field allows you to perform a full-text search for products. It leads to the following search results page:
The search results page has two sections: Faceted search and the actual result list. The faceted search can be used to further limit the search results. You can do so by filtering through main category, sub-category, price, and rating. We’ll talk about the implementation details of how such a faceted search is realized with RediSearch in part two of the blog series. Let me give you a hint by letting you take a look at RedisMart’s debug view:
As you can see, tags and aggregation play a role.
Clicking on the little camera icon in the upper right corner allows you to take an image of something that you want to find within the product catalog. The following photo of Doug didn’t find any other Dougs in our database…
…but it nicely found some headphones.
Let’s assume that you decide on a pair of headphones and want to purchase them. After making your choice, RedisMart allows you to add them to your shopping cart. During the checkout process, you can decide to get them delivered or collect them at a close-by location.
RediSearch’s geo-search powers this local pickup feature. The debug view gives you again a hint of how this is realized behind the scenes.
As soon as a customer completes the purchase, the inventory service gets involved by reducing the number of items in stock. This brings us directly to the backend of the application, which allows us to manage the inventory. RedisMart visualizes how immediate inventory updates are observed on each of the replicated sites. A purchase in the US (GCP us-central1) is replicated with a blink of an eye to Europe (Azure north-europe).
Once again, we’ll cover more details later. The main point here is that you can access the data from a close-by location at a very low network latency, while counter losses are prevented when data is modified concurrently across multiple sites.
You can see the application in action by watching the following video:
We hope you enjoyed reading this first part of the blog series about building a fully-featured retail application with Redis. As you can see, the Redis real-time data platform allows us to address requirements like immediate access (less than 100ms end-to-end latency) to product information by leveraging the document database capabilities of RediSearch + RedisJSON. A combination of RediSearch + RedisGears + RedisAI enables AI-powered image search for finding similar products within the product catalog. In addition, features like faceted and geo-search were covered. Last, but not least, we showed you that you can easily build a geo-replicated, real-time inventory based on Redis Enterprise’s Active-Active feature. With all that, the Redis real-time platform helps retail companies positively impact the overall buying experience, provide the best possible fulfillment experience for customers, and optimize inventories in the most cost-effective way.
Do you want to learn more about the individual services that we implemented for RedisMart? Then stay tuned for the next blog article of the series!
Want to try it yourself? Here are some links to get your hands dirty with Redis as a real-time data platform:
A big thank you to everyone who contributed to this demo application:
We want to dedicate this blog series to the primary developer of the RedisMart application, Martin Forstner. It comes with great sadness to share that he recently passed away. Martin’s knowledge, talent, and sense of humor were second to none. He was much more than a Software Engineer for Redis—he was a colleague, teammate, mentor, and a friend. Rest in peace, Martin, we miss you!