How It's Made

The Story Behind an Instacart Order, Part 2: Browsing and Buying

Instacart

Instacart

Oct 16, 2019

This is the second installment of our “Story Behind an Order” series, where we’re walking you through the technology that surfaces grocery items in our apps, enables storefront browsing, guides the shopper through checkout, and powers our last-mile logistics to get dinner to your door in as fast as an hour. Before you read this post, make sure to check out Part One to see how we gather and normalize our grocery catalog data.


In our last installment, we learned about your last-minute dinner plans — weeknight lemony herbed salmon — and dove into how we get the Salmon Fillet, Meyer Lemons, and Dill item listings into our general grocery catalog. In this second installment, we’ll dive into the tech that allows you to find those ingredients, add them to your cart, and check out with the tap of a button.

Building a searchable catalog

On average a user will make 20 searches per basket before they check out.

We built Instacart to give time back to our customers and our search team works to help customers get the most out of those 20 searches. Problem is: making our 500,000,000 item listings across 20,000 locations easily browsable is really hard to do well. If you add “dill” into the search bar, we need to determine whether you want fresh dill, dried dill, or dill pickles, and rank those suggestions in the order we think is most relevant to you.

To do this, we rely on Elasticsearch, and a seven-year backlog of catalog and purchase data. Here’s the search framework we can apply to this particular query:

1.) Determining user intent

The first thing we need to do is identify intent — based on the search queries, is the searcher using the app to browse options and get inspired or are they here to buy a specific item they have in mind? If a user types “herbs”, for example, we can assume that they are exploring different herbs to top their dish, whereas if they type “organic fresh dill”, the intent is much clearer.

2. Determining product modifiers

In every search query we get a core product — in this case, it’s “dill”. In this next layer of search, we look to see if a customer has added product modifiers, which usually correlate with stronger intent. In this example, “organic” and “fresh” are product modifiers. Other strong product modifiers, like specific brands or departments, can help us better organize results.

3. Matching to the catalog

When a retailer enters their inventory data, they usually organize it by department. If they don’t, we add it to a pre-set list of standardized departments. Once we’ve used our product modifiers to determine what we think is the right intent, we rely on Elasticsearch as our query-to-products matchmaker, as we sift through the catalog database to find relevant products.

An example search tree of what departments and products that may be relevant to our “Organic fresh dill” search.

4. Ranking the results

Lastly, we need to determine which product(s) customers are most likely to purchase and rank them “above the fold”. When surfacing the results in-app, we look to a combination of keyword relevance, historical purchase data (which item is added to baskets most?) to build out the ideal ranking. As more and more items are added to more and more baskets over time, we get a finer-grained understanding of what products are most relevant to each query.

The ranked search result for our query. How do you think we did?

When you make your search for salmon and Meyer lemons, we’ll use this same process of determining intent, querying the catalog, and ranking results to filter out salmon cat food and lemon-scented dish soap!

Calculating dynamic basket totals

So you’ve landed on the search results that match your intent. Before you put the item into your basket, you start to browse by price. In every basket, we need to evaluate logic provided by the customer profile, retailers, and CPG partners in order to apply coupons and deals to the item and basket totals in real-time.

Across our marketplace, we can be running over 10,000,000 deals or discounts that can affect total basket cost.

To present listing prices in our app, we take into account various contextual details tied to the customer, the amount of items in the basket, the retailer, and the specific product brands in the basket.

A ton of different factors can affect the price of the salmon you see on the storefront and in your larger basket total at check out:

  • Listing-specific deals: CPG and brand partners can offer coupons or sales for specific items on the platform
  • Loyalty club discounts: certain retailers offer loyalty club pricing to customers who enter their club member number into their Instacart user profile.
  • Location-based deals: Retailers often set location- or region-specific sales or coupons.
  • Delivery discounts: Partners can sponsor free delivery for first-time orderers, they can also sponsor the waiving of delivery fees if a customer puts certain products in their basket.
  • Bundled item discounts: Brands can offer a certain dollar amount off of your total basket price if you choose to buy a number of their products at once — ten dollars off your total purchase, should you buy 5 products by O Organics, for example. Another common bundled deal is the classic 10 items for $10 sale you usually see in the yogurt aisle.
  • Instacart Express membership: delivery fees are waived on orders over a certain dollar threshold if the orderer is a member of Instacart Express.
  • Gift cards and credits: dollar amounts added or issued to individual customer profiles.
A typical deal customers can find as they browse: this Fresh Atlantic Salmon Fillet listing is subject to time-bound sale pricing.

In order to make sure your basket totals take all of these deals and details into account, we use Elasticsearch to fetch our base product attributes from the catalog (i.e.: simple things like item name, image, and the listings set price), and use a set of simple Ruby logic to apply price transformations to the items you’re browsing and adding to your cart. Once the transformations are applied, we get an adjusted item cost that gets factored into your basket totals.

As all of this is going on, we’re pulling in other contextual information associated with your account, like loyalty cards, express memberships, first-time ordering, and order credits, to apply to your basket totals in real-time. Once we’re confident that the salmon fillet, fresh dill, and Meyer lemon items in cart have undergone the appropriate transformations, and you click ‘place order’, we persist your order information, which will be used by our Fulfilment team to batch your order to shoppers. As part of this order creation we confirm all of our totals calculations, determine the total charge and create a payment authorization via Stripe®, our payments processor.

Up next in the story of this order? Fulfillment. Stay tuned for the next installment of this series, where we’ll dig into the tech that helps shoppers select your order in-store, and the logistics system that navigates orders to your door.


Can’t get enough of Search, Machine Learning, and Dynamic Basket Pricing 🛒? Our Engineering and Product teams are hiring! Check out our current openings.

*Learn more about Engineering at Instacart on our Tech blog.

Instacart

Instacart

Instacart is the leading grocery technology company in North America, partnering with more than 1,400 national, regional, and local retail banners to deliver from more than 80,000 stores across more than 14,000 cities in North America. To read more Instacart posts, you can browse the company blog or search by keyword using the search bar at the top of the page.

Most Recent in How It's Made

One Model to Serve Them All: How Instacart deployed a single Deep Learning pCTR model for multiple surfaces with improved operations and performance along the way

How It's Made

One Model to Serve Them All: How Instacart deployed a single Deep Learning pCTR model for multiple surfaces with improved operations and performance along the way

Authors: Cheng Jia, Peng Qi, Joseph Haraldson, Adway Dhillon, Qiao Jiang, Sharath Rao Introduction Instacart Ads and Ranking Models At Instacart Ads, our focus lies in delivering the utmost relevance in advertisements to our customers, facilitating novel product discovery and enhancing…...

Dec 19, 2023
Monte Carlo, Puppetry and Laughter: The Unexpected Joys of Prompt Engineering

How It's Made

Monte Carlo, Puppetry and Laughter: The Unexpected Joys of Prompt Engineering

Author: Ben Bader The universe of the current Large Language Models (LLMs) engineering is electrifying, to say the least. The industry has been on fire with change since the launch of ChatGPT in November of…...

Dec 19, 2023
Unveiling the Core of Instacart’s Griffin 2.0: A Deep Dive into the Machine Learning Training Platform

How It's Made

Unveiling the Core of Instacart’s Griffin 2.0: A Deep Dive into the Machine Learning Training Platform

Authors: Han Li, Sahil Khanna, Jocelyn De La Rosa, Moping Dou, Sharad Gupta, Chenyang Yu and Rajpal Paryani Background About a year ago, we introduced the first version of Griffin, Instacart’s first ML Platform, detailing its development and support for end-to-end ML in…...

Nov 22, 2023