このページでは、Retail Search でのフィルタと注文について説明します。
フィルタリングのチュートリアル
このチュートリアルでは、商品フィルタリングの例を説明します。
このタスクを Cloud Shell エディタで直接行う際の順を追ったガイダンスについては、[ガイドを表示] をクリックしてください。
以降のセクションでは、[ガイドを表示] をクリックした場合と同じ手順について説明します。
並べ替えのチュートリアル
このチュートリアルでは、検索レスポンス内のアイテムを並べ替える方法について説明します。
このタスクを Cloud Shell エディタで直接行う際の順を追ったガイダンスについては、[ガイドを表示] をクリックしてください。
以降のセクションでは、[ガイドを表示] をクリックした場合と同じ手順について説明します。
データセットの例
このページでは、次のデータセットを例として使用します。例に必要なフィールドのみが含まれています。
フィルタ
Java
フィルタ式の構文は、次の EBNF に要約できます。
# A single expression or multiple expressions that are joint by "AND" or "OR". filter = expression, { " AND " | "OR", expression }; # A expressions can be prefixed with "-" or "NOT" to express a negation. expression = [ "-" | "NOT " ], # A parenthesized expression | "(", expression, ")" # A simple expression applying to a textual field. # Function "ANY" returns true if the field contains any of the literals. ( textual_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 applying 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. # Specify inclusive bound with character 'i' for inclusive or exclusive bound # with character 'e', explicitly. lower_bound = ( double, [ "e" | "i" ] ) | "*"; # An upper_bound is either a double, or "*" which represents infinity. # Specify inclusive bound with character 'i' for inclusive or exclusive bound # with character 'e', explicitly. 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; textual_field = see the table below; numerical_field = see the table below;
サポートされているテキスト項目を次の表にまとめます。
項目 | 説明 |
---|---|
「productId」 | 商品 ID(Product.name の最後のセグメント)。 |
「ブランド」 | 商品ブランド |
「categories」 | Product.categories。 |
「genders」 | Audience.genders。 |
「ageGroups」 | Audience.age_groups。 |
「在庫状況」 | 商品の在庫状況値は「IN_STOCK」、「OUT_OF_STOCK」、「PREORDER」、「BACKORDER」のいずれかです。 |
"colorFamilies" | ColorInfo.color_families。 |
「colors」 | ColorInfo.colors。 |
「sizes」 | Product.sizes。 |
「materials」 | Product.materials。 |
「patterns」 | Product.patterns。 |
「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」 | discount。(original_price - price) ÷ original_price で算出されます。 |
「rating」 | Rating.average_rating。 |
「ratingCount」 | Rating.rating_count。 |
「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。 |
「ブランド」 | 商品ブランド |
「categories」 | Product.categories。 |
「genders」 | Audience.genders。 |
「ageGroups」 | Audience.age_groups。 |
「price」 | PriceInfo.price。 |
「discount」 | discount。(元の価格 - 価格)÷ 価格で算出されます。 |
「rating」 | Rating.average_rating。 |
「ratingCount」 | Rating.rating_count。 |
「attributes.key」 | 商品オブジェクトのカスタム属性。キーは、Product.attributes マップ内の任意のキーです。 |
「inventory(place_id,price)」 | 在庫価格。 |
「inventory(place_id,original_price)」 | 元の在庫価格。 |
「inventory(place_id,attributes.key)」 | 在庫内の数値またはテキストのカスタム属性。 |
デフォルトでは、順序は昇順です。降順は、「desc」接尾辞で指定できます(例: rating desc)。
複数のフィールドによる順序付けは、優先度順のカンマ区切りフィールドを使用することでサポートされます。優先度の低い項目は、優先度が高い同一価格の商品アイテムの順序付けに使用されます。たとえば、「rating desc, price」は、評価が同じである商品を価格によって順序付けます。