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 349
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

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.

I have been working on vertex ai search for retail for large retail services. I really need an expert' advice. This would be a long story so thank you for your consideration and appreciate it if you can give me an advice as much as possible, as soon as possible.

First goal would be efficient relevance and good faceting search.
I would like to share the only one item of products that has been already indexed data catalog.:
{
  "name": "projects/295037490706/locations/global/catalogs/default_catalog/branches/1/products/10000",
  "id": "10000",
  "type": "PRIMARY",
  "primaryProductId": "10000",
  "categories": [
    "Bearings",
    "Mounted Bearings",
    "Mounted Ball Bearings",
    "Take-Up Bearings",
    "Take-Up Bearing Units"
  ],
  "title": "AMI UEST207-23NP 1-7/16 Wide Accu-Loc Nickel Wide SL Plated Take-Up Unit",
  "brands": [
    "AMI Bearings"
  ],
  "languageCode": "en-US",
  "attributes": {
    "count": {
      "numbers": [
        6
      ]
    },
    "Locking": {
      "text": [
        "Concentric collar"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "has_image": {
      "text": [
        "True"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "Insert_Material": {
      "text": [
        "Bearing steel"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "has_aux_data": {
      "text": [
        "False"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "Housing": {
      "text": [
        "Nickel Plated Cast Iron"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "Duty": {
      "text": [
        "Standard"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "shipping": {
      "text": [
        "0.0"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "has_alternates": {
      "text": [
        "False"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "mpn": {
      "text": [
        "UEST207-23NP"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "shipping_weight": {
      "text": [
        "3.6"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "I_D_": {
      "text": [
        "1 7/16 in"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "Seal": {
      "text": [
        "Contact Seal with Slinger"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    },
    "has_tech_specs": {
      "text": [
        "True"
      ],
      "catalogLevelSearchableSnapshot": false,
      "catalogLevelIndexableSnapshot": true
    }
  },
  "priceInfo": {
    "price": 96.83,
    "originalPrice": 96.83,
    "priceRange": {}
  },
  "availability": "IN_STOCK",
  "uri": "uri",
  "images": [
    {
      "uri": "uri"
    }
  ],
  "conditions": [
    "new"
  ],
  "publishTime": "2024-12-16T07:09:29.949806Z"
}
I would like to know if this product structure is good and enough for retail search, what is missing now and what should I update. Thank you.
 
Secondly - FACET - I am really hard on working this part.
Here as you can see it has several attributes keys like "Seal", "shipping_weight", "mpn", "Duty", "Housing","Insert_Material"
And sometimes ofthen over 100k products have more than 30 different facet keys
I extracted all possible facet keys there and noticed that they are over 4000 which is over 200 (vertex ai default one)
 
Actually I tried to do with dynamicFacetSpec which seems to help this but not working.
The facet keys I could see from the search results are always from the facet keys I configured when sending a request to service.
I have never seen facet keys appearing newly after running search engine, service. But you said it's possible. 
I hope it would work in this way you mentioned but I haven't found the correct way yet.
And for example, when I run this service, I needed to fix the facet keys up to 200, then it lacks the main attributes from the products
 
So I found my own solution which may be bad, but let me share it.
- Each product has their own different numbers of attribute keys so I updated the product attributes contaiing attribute keys count. 
- When someone search, then I search with them in order desc of attributes count, then I fetched 10 products which seems to have most of facet keys regarding search query. (sounds okay? I know it's not perfect)
- Then I build facet keys here (which is programmatic, not semantic search) and re-search the products based on search query and generated facet keys.
- This would be looking good but not sure they are relevant option, actually the result was not perfect, worse than searchspring in terms of relevancy measure.
 
----- 🙏🙏🙏🙏🙏 Please help me find the best solution for this dynamic search especially in case of 4000 attributes keys 
 
 
 
Thirdly, We also need to incorporate the facetable attribute data into the searchable description

For ex) if I search 1" pillow block bearing

Thank you for your feedback.

🙏🙏🙏🙏🙏