When implementing a service like Cloud Retail Search that charges for each API request, it can be tempting to optimize for efficiency by caching results or minimizing the amount of times you load response data. This article explains why this is an anti-pattern when using Google Cloud’s Discovery AI solutions and aims to help you understand why you’re better off making more API requests - not fewer.
Let’s get pricing out of the way first. Yes, it costs more to do this. However, the AI model performance will be better, and if your product catalog is optimized, then it will lead to more top-line revenue. Assuming your Cloud Retail Search project had a meaningful ROI and business case to begin with, the cost to send additional API calls should be negligible compared to the up-lift in average order value and conversion rates you should see as a result of implementing the technology. Don’t spend a dollar to save a nickel!
A Real-World Example: Filtering
To understand why this is important, let’s review how filtering search results works:
When you call the Cloud Retail Search endpoint with a user’s search query and receive a search results page, a JSON response is delivered - this includes products in a specific order and dynamic facets.
Once you have this JSON object, it can be tempting to complete all on-page filtering client-side in the browser. If it’s a common search term, you may even cache the results for this specific query behavior and skip calling the Retail API altogether. While it’s tempting to avoid creating additional latency when users are simply filtering and sorting products, the user behavior provides valuable feedback to train the search and recommendations models. However, this does assume that you’re correctly sending user events back to the Retail API.
If users consistently filter by the same attribute (like size) and attribute value (like medium) on every search for, “blue t-shirts” then Cloud Retail Search will not only learn to start placing Size at the top of the dynamic facets, but also put more medium shirts earlier in the search results by default - assuming these users also convert!
This clever logic is an ongoing training process and can take place on thousands of queries, outperforming even the best human merchandisers.
If you’re using the Cloud Retail Search to serve Browse results on your storefront, you may be switching from a CDN-delivered category page to a Retail API-delivered category page instead.
Images, typically the most bandwidth-intensive retrieval, can still be delivered via a CDN. The image URI uploaded with your product data can be a CDN-delivered path.
The closer your ecommerce solution is hosted to Google Cloud, the better. If your solution is hosted on-premises and needs to make an API call to Google every time a page loads, minimizing latency is crucial. A dedicated or partner interconnect can help with this.
You should never cache personalized results from an end user to prevent returning personalized results to a different end user.
When deploying Google Cloud Discovery AI on your ecommerce website for the first time, be sure you fully document and understand your content delivery data flow. For example, if you’re using a CDN such as Cloudflare, you may find that the default cache behavior or configured rules alter search result responses.
Even if you don’t explicitly have caching enabled at the common layers of your application, it’s pretty amazing where unintended caching behavior can occur!
Segment Bot Traffic
If you have implemented client-side loading or a CDN due to bot traffic, it may be time to filter bot traffic to another search solution - preferably a free one. Calls made to the Retail API are not delineated between human and bot traffic, which means you may end up paying for bots to scrape your website. Like some bacteria in your body, some bots, like a search engine indexer, can be good!
Be careful though, bots can create unintended model training results by making searches or browse requests but never converting.
Following this implementation guidance when activating Cloud Retail Search and Recommendations AI should help you get the best top-line revenue results while minimizing costs and performance tradeoffs. The additional Retail API costs should be offset by increased revenue, and fully understanding how data flows between your infrastructure and your end users will help you design a thoughtful solution.