本頁面說明如何使用搜尋功能篩選及排序。
語意篩選器可最佳化非預設排序
商家適用的 Vertex AI Search 旨在顯示各種結果,包括熱門或趨勢商品等關聯性較低的項目。這在預設搜尋 (依相關性排序) 中很有效,但在使用 order_by
功能的非預設搜尋中 (例如依價格排序),較不相關的項目可能會因價格較低而更顯眼。
為改善這項影響,Vertex AI Search for commerce 導入了以語意嵌入為基礎的篩選功能,可從非預設搜尋結果中移除這些較不相關的項目,提升使用者體驗。
不過,這項預期行為可能會導致整體搜尋結果減少。停用篩選功能可能會影響搜尋結果品質。因此,如果擔心搜尋結果數量較少,請與支援團隊聯絡。
教學課程:篩選功能
本教學課程將示範篩選功能。可讓您依據自己或客戶的需求精細調整搜尋要求。您可以按照一或多個欄位篩選,也可以按照文字和/或數值欄位篩選。您可以使用運算式語言為每個欄位建立述詞,也可以透過邏輯運算子合併不同的運算式。舉例來說,尋找鞋子的購物者可以使用篩選器,將搜尋範圍縮小至偏好的品牌和顏色。
如要直接在 Cloud Shell 編輯器中按照逐步指南操作,請按一下「Guide me」(逐步引導):
教學課程:排序功能
本教學課程會說明如何為搜尋回應中的項目排序。當使用者在您的網站上搜尋產品時,系統會根據多個欄位排序顯示結果。舉例來說,使用者正在搜尋價格和折扣最優惠的洋裝。這裡的價格和折扣是多個欄位。使用者會看到依價格排序的洋裝,價格相同的洋裝則會依折扣排序。
如要直接在 Cloud Shell 編輯器中按照逐步指南操作,請按一下「Guide me」(逐步引導):
範例資料集
本頁會使用下列資料集做為範例。範例中只包含必要的欄位。
篩選器
Java
篩選運算式語法可歸納為下列 EBNF:
# A single expression or multiple expressions that are joined by "AND" or "OR". filter = expression, { " AND " | "OR", expression }; # Expressions can be prefixed with "-" or "NOT" to express a negation. expression = [ "-" | "NOT " ], # A parenthetical expression. | "(", expression, ")" # A simple expression applying to a text field. # Function "ANY" returns true if the field contains any of the literals. ( text_field, ":", "ANY", "(", literal, { ",", literal }, ")" # A simple expression applying to a numerical field. Function "IN" returns true # if a field value is within the range. By default, lower_bound is inclusive and # upper_bound is exclusive. | numerical_field, ":", "IN", "(", lower_bound, ",", upper_bound, ")" # A simple expression that applies to a numerical field and compares with a double value. | numerical_field, comparison, double ); # A lower_bound is either a double or "*", which represents negative infinity. # Explicitly specify inclusive bound with the character 'i' or exclusive bound # with the character 'e'. lower_bound = ( double, [ "e" | "i" ] ) | "*"; # An upper_bound is either a double or "*", which represents infinity. # Explicitly specify inclusive bound with the character 'i' or exclusive bound # with the character 'e'. upper_bound = ( double, [ "e" | "i" ] ) | "*"; # Supported comparison operators. comparison = "<=" | "<" | ">=" | ">" | "="; # A literal is any double quoted string. You must escape backslash (\) and # quote (") characters. literal = double quoted string; text_field = see the table below; numerical_field = see the table below;
下表匯總了支援的文字欄位。
欄位 | 說明 |
---|---|
「productId」 | 產品 ID (Product.name 的最後一個區隔)。 |
「brands」 | 產品品牌。 |
「類別」 | Product.categories。 |
「genders」 | 目標對象的性別。 |
「ageGroups」 | 目標對象的年齡層。 |
「availability」 | 產品供應情形。值為「IN_STOCK」、「OUT_OF_STOCK」、「PREORDER」或「BACKORDER」。 |
「colorFamilies」 | ColorInfo.color_families。 |
「colors」 | ColorInfo.colors。 |
「sizes」 | Product.sizes。 |
「materials」 | 產品材料。 |
「patterns」 | 產品模式。 |
「條件」 | The Product.conditions. |
「attributes.key」 | 產品物件中的文字自訂屬性。如果屬性值為文字,則鍵可以是 Product.attributes 對應中的任何鍵。 |
「pickupInStore」 | 類型為「pickup-in-store」的 FulfillmentInfo.place_ids。 |
「shipToStore」 | 類型為「ship-to-store」的 FulfillmentInfo.place_ids。 |
「sameDayDelivery」 | 類型為「same-day-delivery」的 FulfillmentInfo.place_ids。 |
「nextDayDelivery」 | 類型為「next-day-delivery」的 FulfillmentInfo.place_ids。 |
「customFulfillment1」 | 類型為「custom-type-1」的 FulfillmentInfo.place_ids。 |
「customFulfillment2」 | 類型為「custom-type-2」的 FulfillmentInfo.place_ids。 |
「customFulfillment3」 | 類型為「custom-type-3」的 FulfillmentInfo.place_ids。 |
「customFulfillment4」 | 類型為「custom-type-4」的 FulfillmentInfo.place_ids。 |
「customFulfillment5」 | 類型為「custom-type-5」的 FulfillmentInfo.place_ids。 |
"inventory(place_id,attributes.key)" | 商品目錄中的文字自訂屬性。 |
下表匯總支援的數值欄位。
欄位 | 說明 |
---|---|
「price」 | PriceInfo.price。 |
「discount」 | 折扣。計算方式為 (原價 - 價格) / 原價。 |
「rating」 | Rating.average_rating。 |
「ratingCount」 | 評分。評分次數。 |
「attributes.key」 | 產品物件中的數值自訂屬性。如果屬性值為數值,則鍵可以是 Product.attributes 對應中的任何鍵。 |
"inventory(place_id,price)" | 廣告空間價格。 |
「inventory(place_id,original_price)」 | 原始商品目錄價格。 |
"inventory(place_id,attributes.key)" | 商品目錄中的數值自訂屬性。 |
最多可使用 10 個巢狀連詞或析取。
舉例來說,如要在下列情況中搜尋 Google 產品,您可以將 query
設為「Google」,並將 filter
設為下表顯示的值:
情境 | 篩選 |
---|---|
不是 Pixel 配件 | 「NOT categories: ANY(\"Pixel > featured accessories\")」 |
「比 100 美元便宜」 | "price: IN(*, 100.0e)" |
「Nest 音箱價格不低於 80 美元」 | "(categories: ANY(\"Nest > speakers and displays\")) AND (price: IN(80.0i, *))" |
訂單
Java
下表匯總了支援排序的欄位。
欄位 | 說明 |
---|---|
「productId」 | 產品 ID (Product.name 的最後一個區隔)。 |
"title" | Product.title。 |
「brands」 | 產品品牌。 |
「類別」 | Product.categories。 |
「genders」 | 目標對象的性別。 |
「ageGroups」 | 目標對象的年齡層。 |
「price」 | PriceInfo.price。 |
「discount」 | 折扣。計算方式為 (原價 - 價格) / 價格。 |
「rating」 | Rating.average_rating。 |
「ratingCount」 | 評分。評分次數。 |
「attributes.key」 | 產品物件中的自訂屬性。索引鍵可以是 Product.attributes 地圖中的任何索引鍵。 |
"inventory(place_id,price)" | 廣告空間價格。 |
「inventory(place_id,original_price)」 | 原始商品目錄價格。 |
"inventory(place_id,attributes.key)" | 商品目錄中的數字或文字自訂屬性。 |
預設為遞增順序。遞減順序可透過「desc」後置字元指定,例如「rating desc」。
如果是具有多個值的數值欄位 (例如重複欄位或為變體產品設定的欄位),系統會使用最小值以遞增順序排序,並使用最大值以遞減順序排序。
系統支援依多個欄位排序,只要以半形逗號分隔欄位並依優先順序排列即可。如果優先順序較高的欄位值相同,系統就會使用優先順序較低的欄位來決定項目的排序。舉例來說,「rating desc, price」 會依價格為評分相同的商品排序。