搜尋和瀏覽

本文旨在釐清 AI Commerce Search 中搜尋和瀏覽功能之間的差異,並探討如何有效設定各項功能,進而充分發揮其效益。

瞭解核心差異

搜尋和瀏覽功能都能協助顧客尋找產品,但兩者適用於不同的使用者歷程,因此需要不同的設定。

由使用者意圖驅動,購物者輸入特定查詢,例如「紅色慢跑鞋」。AI Commerce Search 會分析這項查詢,瞭解使用者的需求,並傳回經過收益最佳化的相關產品。

簡而言之,AI Commerce Search 負責產品的關聯性和排名 (收益最佳化)。

瀏覽

購物者可依預先定義的類別瀏覽產品資訊,並依品牌、類別或促銷活動等屬性排序,例如「男裝」類別中的「襯衫」。這些類別由你定義,並在其中顯示產品。

您必須負責列出相關產品 (透過篩選器),AI 商務搜尋則負責排名 (以收益為最佳化目標)。

設定搜尋和瀏覽功能

AI Commerce Search 的優點在於,搜尋和瀏覽要求都使用統一的 API。

設定搜尋功能

搜尋的使用者事件應包含下列欄位,以及使用者事件的其他標準必填欄位 (eventType = "search"):

  • 文字查詢:搜尋要求的核心。可擷取使用者的搜尋意圖。
  • 篩選條件 (選用):允許使用者套用品牌、價格範圍或顏色等商情項目,縮小搜尋結果範圍。
  • 排名和個人化:AI Commerce Search 會根據關聯性和潛在收益,自動調整搜尋結果的排名。個人化功能會根據個別使用者行為,進一步調整搜尋結果。

  # Construct the search request
  search_request = {
      "query": "red running shoes", # User's search query
      "filter": "brand:ANY('Nike')", # Optional filter
      "page_size": 10 # Number of results per page
  }

# Send the request to the VAIS:Commerce API search_response = client.search(search_request)

# Process the search results for product in search_response.results: print(product.title, product.price)

如要瞭解如何使用搜尋功能進行基本查詢,包括文字查詢搜尋、瀏覽搜尋、分頁、最佳化和個人化搜尋結果,請參閱「取得搜尋結果」。

設定瀏覽

瀏覽搜尋的使用者事件必須包含下列欄位,以及使用者事件的其他標準必填欄位 (瀏覽事件的 eventType = "search"):

  • 網頁類別page_categories 代表產品顯示的類別或橫幅。不過,在實體用戶端程式庫或舊版 API 中,這個欄位可能仍會顯示為單數的 page_category。複數形式可以與目錄中的 categories[] 相同。但必須代表篩選器所代表的類別。

  • 必要篩選條件:定義產品納入瀏覽結果的條件。確保類別中只顯示相關產品。

  • 事件與要求一致:與瀏覽動作對應的使用者事件應包含相同的 page_categories 和篩選器值,與 API 要求中傳遞的值相符。

  • 瀏覽並篩選具有相同值的集合:如要使用相同的值設定 pageCategories (瀏覽) 和 attributes.pageCategories (篩選) 欄位,請建立不可搜尋的 attributes.pageCategories 物件,並列出這項產品應顯示的所有頁面,方便進行篩選。

如這些範例所示,瀏覽篩選器通常是您提供的自訂屬性,例如 categorycategoryid 欄位。

以下是上述四種不同的瀏覽要求選項範例。(只要選擇一種格式即可)。

  # a browse request with a custom category attribute
  browse_request = {
      "page_categories": ["Men's > Clothing > Shirts"], # Represents full taxonomy Path on the site
      "filter": "category:ANY('Shirts') AND gender: ANY('Male')", # Compulsory filter on custom attribute
      "page_size": 10
  }
  # a browse request showing category ID (Men's shirts custom id)
  browse_request = {
      "page_categories": ["Men's > Clothing > Shirts"],
      "filter": "categoryid:ANY(1234)", # Another custom attribute for categories
      "page_size": 10
  }
  # another example showing category ID's (Men's shirts custom id)
  browse_request = {
      "page_categories": ["1234"],  # Also ok to use unique category id's here
      "filter": "categoryid:ANY(1234)",
      "page_size": 10
  }
  # browse and filter set with the same value
  browse_request = {
      "page_category": ["Men's > Clothing > Shirts"], # Browse category
      "filter": "attributes.pageCategories:ANY('Men's > Clothing > Shirts')", # Compulsory filter
      "page_size": 10 # Number of results per page
  }
  # Send the request to the API
  browse_response = client.search(browse_request)
  # Process the browse results
  for product in browse_response.results:
      print(product.title, product.price)