Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Dynamic Facet search.

Bronze 1
 
 

Dear Developers,

I am currently working on implementing Google Retail Search in my application. The challenge I am facing is that I have over 200 custom product attributes, over 4000, making it impractical to add all of them in the FacetSpecs during searching requests. However, I need to retrieve facets value and their count to build a user-friendly filter.

I attempted to use dynamic Facets, but unfortunately, I could not find any specific documentation on how to retrieve dynamic facet data when using Search API. Hence, I am requesting suggestions from experienced developers within the community. Any help provided will be greatly appreciated.

Thank you.

Solved Solved
0 2 368
1 ACCEPTED SOLUTION

Hi @pavlodidushko,

Welcome to Google Cloud Community!

It looks like you're facing a common challenge with large attribute sets in Google Retail Search. Here's a breakdown of a possible solution, focusing on strategies since there isn't a clear method for "dynamic facets" retrieval in the search API:

Core Problem: You have too many attributes to predefine in FacetSpecs, and you need facet information for filtering.

Possible Solution Strategy: A Combination Approach

The main idea is to avoid retrieving all facet data at once. Instead, retrieve it on-demand based on the user's interactions with the initial search results and filters. Here are some approaches you can consider:

Initial Search:

  • Use a small set (5-10) of your most important attributes (e.g., category, brand) in initial FacetSpecs.
  • Display results & basic filters from initial facets.

On-Demand Facet Retrieval:

  • When users expand a facet group or interact with a filter, determine which additional attributes from the product metadata you want to display (e.g. "material," "color,").
  • Make a secondary search call with those attributes as FacetSpecs, filtered to only include results of the initial search and with all previous filters applied.
  • Use returned facets to enhance the filter UI.

Filter update:

  • When the user selects a new filter, re-execute the initial search query.
  • Update the facets based on the latest results.

Key Considerations

  • Avoid preloading all facets.
  • Attribute Grouping: Organize your 4000+ attributes into logical groups (e.g., "material," "color," "technical specs," "compatibility"). This helps with the "what to display" logic, and makes retrieving them more efficient. You may want to dynamically generate groups on the UI based on most popular facet selections.
  • Caching: Implement caching to avoid redundant requests for facet data that has already been retrieved and to avoid too many API calls.
  • Performance: Optimize the FacetSpecs construction for each request to minimize request size and processing time. Keep the requests small.
  • Monitoring: Track user interactions and facet usage to understand which attributes are most valuable for your customers and optimize your strategy accordingly.
  • Consider the search API limit: There is a limit on the number of facets and filter rules that can be sent on the Google Cloud Retail API. Keep the request sizes small.

You can also read the following documentation for more details:

Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.

View solution in original post

2 REPLIES 2