本文档旨在阐明 AI Commerce Search 中的搜索和浏览功能之间的区别,以便探讨如何有效地配置每项功能并充分利用它们。
了解核心差异
搜索和浏览功能都可以帮助客户找到商品,但它们适用于不同的用户历程,并且需要不同的配置。
搜索
搜索功能由用户意图驱动,购物者会输入特定查询,例如“红色跑鞋”。 AI Commerce Search 会分析此查询,了解用户的需求,并返回针对收入进行了优化的相关商品。
简而言之,对于搜索,AI Commerce Search 负责确保商品的相关性并对商品进行排名(针对收入进行了优化 )。
浏览
浏览功能由预定义的类别引导,购物者可以浏览按品牌、类别或促销活动等属性整理的商品列表,例如男装 类别中的衬衫 。您可以定义这些类别,并在其中展示商品。
您负责确保所列商品的相关性(通过过滤条件),而 AI Commerce Search 负责对商品进行排名(针对收入进行了优化)。
配置搜索和浏览
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[]相同。它必须表示过滤条件所代表的类别。强制性过滤条件:定义将商品纳入浏览结果的标准。这可确保类别中仅显示相关商品。
事件与请求之间的一致性:与浏览操作对应的用户事件应包含与 API 请求中传递的
page_categories和过滤条件值相同的值。浏览和过滤条件集具有相同的值:如需为
pageCategories(浏览)和attributes.pageCategories(过滤条件)字段设置相同的值,请创建一个不可搜索的attributes.pageCategories对象,并列出此商品应显示在其中的每个网页,以便进行过滤。
对于浏览过滤条件,这些示例中显示的 category 或 categoryid 等字段通常是您提供的自定义属性。
以下是上述四个不同浏览请求选项的示例。(只需选择一种格式即可)。
# 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)