All eyes on AI: 2026 predictions – The shifts that will shape your stack.

Read now

Tutorial

Real-time Local Inventory Search Using Redis

February 26, 202615 minute read
Prasan Rajpurohit
Prasan Rajpurohit
William Johnston
William Johnston
TL;DR:
Build a local inventory search with Redis by storing product quantities per store as JSON documents with geospatial coordinates, then querying them with Redis's geo-radius search. Customers search by SKU and location, and Redis returns matching stores within a given radius — optionally sorted by distance — enabling buy-online-pickup-in-store (BOPIS) experiences.
GITHUB CODE
Below is a command to the clone the source code for the application used in this tutorial

#What you'll learn

  • What real-time local inventory search is and why it matters for omnichannel retail
  • How to model store inventory data with geospatial coordinates in Redis
  • How to query nearby store product availability using Redis geo-spatial search
  • How to sort inventory results by distance from the customer's location
  • How to build inventorySearch and inventorySearchWithDistance APIs with Redis

#What is real-time local inventory search?

Real-time local inventory search is a method of utilizing advanced product search capabilities across a group of stores or warehouses in a region or geographic area by which a retailer can enhance the customer experience with a localized view of inventory while fulfilling orders from the closest store possible.
Geospatial search of merchandise local to the consumer helps sell stock faster, lowers inventory levels, and thus increases inventory turnover ratio. Consumers locate a product online, place the order in their browser or mobile device, and pick up at nearest store location. This is called "buy-online-pickup-in-store" (BOPIS)

#What are the current challenges in real-time inventory?

  • Over and under-stocking: While adopting a multi-channel business model (online & in store), lack of inventory visibility results in over and under-stocking of inventory in different regions and stores.
  • Consumers seek convenience: The ability to search across regional store locations and pickup merchandise immediately rather than wait for shipping is a key differentiator for retailers.
  • Consumers seek speed: All retailers, even small or family-run, must compete against the customer experience of large online retailers like Alibaba, FlipKart, Shopee, and Amazon.
  • High inventory costs: Retailers seek to lower inventory costs by eliminating missed sales from out-of-stock scenarios which also leads to higher "inventory turnover ratios."
  • Brand value: Inaccurate store inventory counts lead to frustrated customers and lower sales. The operational pain will impact the status quo.

#Why should you use Redis for local inventory search?

  • Accurate location/regional inventory search: Redis geospatial search capabilities enable retailers to provide local inventories by store location across geographies and regions based on a consumer's location. This enables a real-time view of store inventory and a seamless BOPIS shopping experience.
  • Consistent and accurate inventory view across multichannel and omnichannel experiences: Accurate inventory information no matter what channel the shopper is using, in-store, kiosk, online, or mobile. Redis provides a single source of truth for inventory information across all channels.
  • Real-time search performance at scale: Redis's real-time search and query engine allows retailers to provide instant application and inventory search responses and scale performance effortlessly during peak periods.
If you're new to geospatial data in Redis, see the Getting Started with Geo tutorial for foundational concepts.

#How does real-time local inventory search work with Redis?

Architecture diagram showing how Redis geo-spatial queries connect a customer's location to nearby store inventory across multiple retail locations
Redis provides geospatial search capabilities across a group of stores or warehouses in a region or geographic area allowing a retailer to quickly show the available inventory local to the customer.
Redis processes event streams, keeping store inventories up-to-date in real-time. This enhances the customer experience with localized, accurate search of inventory while fulfilling orders from the nearest and fewest stores possible.
This solution lowers days sales of inventory (DSI), selling inventory faster and carrying less inventory for increased revenue generation and profits over a shorter time period.
It also reduces fulfillment costs to home and local stores enhancing a retailer's ability to fulfill orders with the lowest delivery and shipping costs.
CUSTOMER PROOF POINTS
Redis on Google Cloud Platform enables Ulta Beauty to build a "digital store of the future"

#How do you build a real-time local inventory search with Redis?

GITHUB CODE
Below is a command to the clone the source code for the application used in this tutorial

#How do you set up the data?

Once the application source code is downloaded, run following commands to populate data in Redis:
The demo uses two collections:
  • Product collection: Stores product details like productId, name, price, image, and other details
Redis Insight screenshot displaying product JSON documents with fields for productId, name, price, and image URL
TIP
Download Redis Insight to view your Redis data or to play with raw Redis commands in the workbench.
  • StoresInventory collection: Stores product quantity available at different local stores.
For demo purpose, we are using the below regions in New York, US as store locations. Products are mapped to these location stores with a storeId and quantity.
Map of New York State highlighting ten demo store locations used for geo-spatial inventory search
Redis Insight screenshot showing StoresInventory JSON documents with storeId, SKU, quantity, and geo-coordinates per store
Let's build the following APIs to demonstrate geospatial search using Redis:
  • InventorySearch API: Search Products in local stores within a search radius.
  • InventorySearchWithDistance API: Search Product in local stores within search radius and sort results by distance from current user location to store.

#How does the InventorySearch API work?

The code that follows shows an example API request and response for the inventorySearch API:

#inventorySearch API Request

#inventorySearch API Response

When you make a request, it goes through the API gateway to the inventory service. Ultimately, it ends up calling an inventorySearch function which looks as follows:

#How does the InventorySearchWithDistance API work?

The code that follows shows an example API request and response for inventorySearchWithDistance API:

#inventorySearchWithDistance API request

#inventorySearchWithDistance API response

When you make a request, it goes through the API gateway to the inventory service. Ultimately, it ends up calling an inventorySearchWithDistance function which looks as follows:

#Next steps

Now that you've seen how to build a local inventory search with Redis geo-spatial queries, here are some ways to go further:
  • Add available-to-promise logic: Combine local inventory search with Available to Promise (ATP) to show customers real-time reservable quantities, not just raw stock counts.
  • Learn geospatial fundamentals: If you haven't already, work through the Getting Started with Geo tutorial to deepen your understanding of Redis GEOSEARCH and related commands.
  • Build an omnichannel store finder: Extend the search API to return store hours, curbside pickup availability, and shipping estimates alongside inventory data.
  • Add real-time stock updates: Use Redis Streams to process point-of-sale events and keep store inventory counts accurate in real time.

#Additional resources

Real time inventory with Redis
General