From 326576f696e5890ff240d362e81efba94b835f7e Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 18 Oct 2021 22:16:15 +0000 Subject: [PATCH] feat: add search mode to search request (#108) ...If not specified, a single search request triggers both product search and faceted search. - [ ] Regenerate this pull request now. PiperOrigin-RevId: 404039072 Source-Link: https://github.com/googleapis/googleapis/commit/8ef531eaf6e03d709b0dabf1e2202c16685a96d8 Source-Link: https://github.com/googleapis/googleapis-gen/commit/86e91097a445a4b0972a20e4b0e3e87f9aadd2c0 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODZlOTEwOTdhNDQ1YTRiMDk3MmEyMGU0YjBlM2U4N2Y5YWFkZDJjMCJ9 docs: Keep the API doc up-to-date feat: update grpc service config settings to reflect correct API deadlines --- .../services/product_service/async_client.py | 2 +- .../services/product_service/client.py | 2 +- google/cloud/retail_v2/types/common.py | 6 +-- google/cloud/retail_v2/types/product.py | 11 ++-- .../cloud/retail_v2/types/product_service.py | 10 ++-- .../cloud/retail_v2/types/search_service.py | 51 +++++++++++++------ google/cloud/retail_v2/types/user_event.py | 8 +-- scripts/fixup_retail_v2_keywords.py | 2 +- 8 files changed, 59 insertions(+), 33 deletions(-) diff --git a/google/cloud/retail_v2/services/product_service/async_client.py b/google/cloud/retail_v2/services/product_service/async_client.py index 5e95bbd6..20fc951e 100644 --- a/google/cloud/retail_v2/services/product_service/async_client.py +++ b/google/cloud/retail_v2/services/product_service/async_client.py @@ -960,7 +960,7 @@ async def add_fulfillment_places( google.api_core.operation_async.AsyncOperation: An object representing a long-running operation. - The result type for the operation will be :class:`google.cloud.retail_v2.types.AddFulfillmentPlacesResponse` Response of the RemoveFulfillmentPlacesRequest. Currently empty because + The result type for the operation will be :class:`google.cloud.retail_v2.types.AddFulfillmentPlacesResponse` Response of the AddFulfillmentPlacesRequest. Currently empty because there is no meaningful response populated from the [AddFulfillmentPlaces][] method. diff --git a/google/cloud/retail_v2/services/product_service/client.py b/google/cloud/retail_v2/services/product_service/client.py index 77b76cd6..d8ccee41 100644 --- a/google/cloud/retail_v2/services/product_service/client.py +++ b/google/cloud/retail_v2/services/product_service/client.py @@ -1157,7 +1157,7 @@ def add_fulfillment_places( google.api_core.operation.Operation: An object representing a long-running operation. - The result type for the operation will be :class:`google.cloud.retail_v2.types.AddFulfillmentPlacesResponse` Response of the RemoveFulfillmentPlacesRequest. Currently empty because + The result type for the operation will be :class:`google.cloud.retail_v2.types.AddFulfillmentPlacesResponse` Response of the AddFulfillmentPlacesRequest. Currently empty because there is no meaningful response populated from the [AddFulfillmentPlaces][] method. diff --git a/google/cloud/retail_v2/types/common.py b/google/cloud/retail_v2/types/common.py index 676bf19c..94ba5a1c 100644 --- a/google/cloud/retail_v2/types/common.py +++ b/google/cloud/retail_v2/types/common.py @@ -102,7 +102,7 @@ class ColorInfo(proto.Message): only 1 color. May consider using single "Mixed" instead of multiple values. - A maximum of 5 colors are allowed. Each value must be a + A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. @@ -213,8 +213,8 @@ class FulfillmentInfo(proto.Message): or the region IDs for [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2.FulfillmentInfo.type]. - A maximum of 2000 values are allowed. Each value must be a - string with a length limit of 10 characters, matching the + A maximum of 3000 values are allowed. Each value must be a + string with a length limit of 30 characters, matching the pattern [a-zA-Z0-9\_-]+, such as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is returned. """ diff --git a/google/cloud/retail_v2/types/product.py b/google/cloud/retail_v2/types/product.py index dc5ddcd5..35da629e 100644 --- a/google/cloud/retail_v2/types/product.py +++ b/google/cloud/retail_v2/types/product.py @@ -44,12 +44,19 @@ class Product(proto.Message): and [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + [expire_time][google.cloud.retail.v2.Product.expire_time] + must be later than + [available_time][google.cloud.retail.v2.Product.available_time] + and + [publish_time][google.cloud.retail.v2.Product.publish_time], + otherwise an INVALID_ARGUMENT error is thrown. + Google Merchant Center property `expiration_date `__. ttl (google.protobuf.duration_pb2.Duration): Input only. The TTL (time to live) of the product. - If it is set, + If it is set, it must be a non-negative value, and [expire_time][google.cloud.retail.v2.Product.expire_time] is set as current timestamp plus [ttl][google.cloud.retail.v2.Product.ttl]. The derived @@ -69,8 +76,6 @@ class Product(proto.Message): name (str): Immutable. Full resource name of the product, such as ``projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id``. - - The branch ID must be "default_branch". id (str): Immutable. [Product][google.cloud.retail.v2.Product] identifier, which is the final component of diff --git a/google/cloud/retail_v2/types/product_service.py b/google/cloud/retail_v2/types/product_service.py index 45c9db6e..c880c547 100644 --- a/google/cloud/retail_v2/types/product_service.py +++ b/google/cloud/retail_v2/types/product_service.py @@ -357,7 +357,7 @@ class SetInventoryRequest(proto.Message): found, the inventory update will still be processed and retained for at most 1 day until the [Product][google.cloud.retail.v2.Product] is created. If set - to false, an INVALID_ARGUMENT error is returned if the + to false, a NOT_FOUND error is returned if the [Product][google.cloud.retail.v2.Product] is not found. """ @@ -446,7 +446,7 @@ class AddFulfillmentPlacesRequest(proto.Message): fulfillment information will still be processed and retained for at most 1 day and processed once the [Product][google.cloud.retail.v2.Product] is created. If set - to false, an INVALID_ARGUMENT error is returned if the + to false, a NOT_FOUND error is returned if the [Product][google.cloud.retail.v2.Product] is not found. """ @@ -466,8 +466,8 @@ class AddFulfillmentPlacesMetadata(proto.Message): class AddFulfillmentPlacesResponse(proto.Message): - r"""Response of the RemoveFulfillmentPlacesRequest. Currently empty - because there is no meaningful response populated from the + r"""Response of the AddFulfillmentPlacesRequest. Currently empty because + there is no meaningful response populated from the [AddFulfillmentPlaces][] method. """ @@ -531,7 +531,7 @@ class RemoveFulfillmentPlacesRequest(proto.Message): fulfillment information will still be processed and retained for at most 1 day and processed once the [Product][google.cloud.retail.v2.Product] is created. If set - to false, an INVALID_ARGUMENT error is returned if the + to false, a NOT_FOUND error is returned if the [Product][google.cloud.retail.v2.Product] is not found. """ diff --git a/google/cloud/retail_v2/types/search_service.py b/google/cloud/retail_v2/types/search_service.py index c1fe08ba..c6ae7b7b 100644 --- a/google/cloud/retail_v2/types/search_service.py +++ b/google/cloud/retail_v2/types/search_service.py @@ -36,12 +36,9 @@ class SearchRequest(proto.Message): Required. The resource name of the search engine placement, such as ``projects/*/locations/global/catalogs/default_catalog/placements/default_search``. - This field is used to identify the set of models that will - be used to make the search. - - We currently support one placement with the following ID: - - - ``default_search``. + This field is used to identify the serving configuration + name and the set of models that will be used to make the + search. branch (str): The branch resource name, such as ``projects/*/locations/global/catalogs/default_catalog/branches/0``. @@ -94,7 +91,8 @@ class SearchRequest(proto.Message): The filter syntax consists of an expression language for constructing a predicate from one or more fields of the products being filtered. Filter expression is - case-sensitive. + case-sensitive. See more details at this `user + guide `__. If this field is unrecognizable, an INVALID_ARGUMENT is returned. @@ -116,7 +114,8 @@ class SearchRequest(proto.Message): ordered by a field in an [Product][google.cloud.retail.v2.Product] object. Leave it unset if ordered by relevance. OrderBy expression is - case-sensitive. + case-sensitive. See more details at this `user + guide `__. If this field is unrecognizable, an INVALID_ARGUMENT is returned. @@ -134,12 +133,21 @@ class SearchRequest(proto.Message): Contact Retail Search support team if you are interested in using dynamic facet feature. boost_spec (google.cloud.retail_v2.types.SearchRequest.BoostSpec): - Boost specification to boost certain - products. + Boost specification to boost certain products. See more + details at this `user + guide `__. + + Notice that if both [ServingConfig.boost_control_ids][] and + [SearchRequest.boost_spec] are set, the boost conditions + from both places are evaluated. If a search request matches + multiple boost conditions, the final boost score is equal to + the sum of the boost scores from all matched boost + conditions. query_expansion_spec (google.cloud.retail_v2.types.SearchRequest.QueryExpansionSpec): - The query expansion specification that - specifies the conditions under which query - expansion will occur. + The query expansion specification that specifies the + conditions under which query expansion will occur. See more + details at this `user + guide `__. variant_rollup_keys (Sequence[str]): The keys to fetch and rollup the matching [variant][google.cloud.retail.v2.Product.Type.VARIANT] @@ -165,6 +173,7 @@ class SearchRequest(proto.Message): - price - originalPrice - discount + - inventory(place_id,price) - attributes.key, where key is any key in the [Product.attributes][google.cloud.retail.v2.Product.attributes] map. @@ -230,8 +239,18 @@ class SearchRequest(proto.Message): promotions. For instance, a special sale page may have the category hierarchy: "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + search_mode (google.cloud.retail_v2.types.SearchRequest.SearchMode): + The search mode of the search request. If not + specified, a single search request triggers both + product search and faceted search. """ + class SearchMode(proto.Enum): + r"""The search mode of each search request.""" + SEARCH_MODE_UNSPECIFIED = 0 + PRODUCT_SEARCH_ONLY = 1 + FACETED_SEARCH_ONLY = 2 + class FacetSpec(proto.Message): r"""A facet specification to perform faceted search. @@ -345,7 +364,8 @@ class FacetKey(proto.Message): - "discount" - "rating" - "ratingCount" - - "attributes.key". + - "attributes.key" + - "inventory(place_id,price)". intervals (Sequence[google.cloud.retail_v2.types.Interval]): Set only if values should be bucketized into intervals. Must be set for facets with numerical @@ -586,6 +606,7 @@ class Condition(proto.Enum): ) variant_rollup_keys = proto.RepeatedField(proto.STRING, number=17,) page_categories = proto.RepeatedField(proto.STRING, number=23,) + search_mode = proto.Field(proto.ENUM, number=31, enum=SearchMode,) class SearchResponse(proto.Message): @@ -772,7 +793,7 @@ class QueryExpansionInfo(proto.Message): pinned_result_count (int): Number of pinned results. This field will only be set when expansion happens and - [SearchRequest.query_expansion_spec.pin_unexpanded_results][] + [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] is set to true. """ diff --git a/google/cloud/retail_v2/types/user_event.py b/google/cloud/retail_v2/types/user_event.py index 790656d1..d26a6bfd 100644 --- a/google/cloud/retail_v2/types/user_event.py +++ b/google/cloud/retail_v2/types/user_event.py @@ -121,12 +121,12 @@ class UserEvent(proto.Message): In a ``search`` event, this field represents the products returned to the end user on the current page (the end user - may have not finished broswing the whole page yet). When a + may have not finished browsing the whole page yet). When a new page is returned to the end user, after pagination/filtering/ordering even for the same query, a new ``search`` event with different [product_details][google.cloud.retail.v2.UserEvent.product_details] - is desired. The end user may have not finished broswing the + is desired. The end user may have not finished browsing the whole page yet. completion_detail (google.cloud.retail_v2.types.CompletionDetail): The main completion details related to the event. @@ -149,7 +149,7 @@ class UserEvent(proto.Message): site. Users can arrive at the site by coming to the site directly, or coming through Google search, and etc. cart_id (str): - The id or name of the associated shopping cart. This id is + The ID or name of the associated shopping cart. This ID is used to associate multiple items added or present in the cart before purchase. @@ -254,7 +254,7 @@ class UserEvent(proto.Message): JavaScript pixel and Google Tag Manager, this value is filled in automatically. page_view_id (str): - A unique id of a web page view. + A unique ID of a web page view. This should be kept the same for all user events triggered from the same pageview. For example, an item detail page diff --git a/scripts/fixup_retail_v2_keywords.py b/scripts/fixup_retail_v2_keywords.py index 5cc9231f..2688d8b7 100644 --- a/scripts/fixup_retail_v2_keywords.py +++ b/scripts/fixup_retail_v2_keywords.py @@ -55,7 +55,7 @@ class retailCallTransformer(cst.CSTTransformer): 'purge_user_events': ('parent', 'filter', 'force', ), 'rejoin_user_events': ('parent', 'user_event_rejoin_scope', ), 'remove_fulfillment_places': ('product', 'type_', 'place_ids', 'remove_time', 'allow_missing', ), - 'search': ('placement', 'visitor_id', 'branch', 'query', 'user_info', 'page_size', 'page_token', 'offset', 'filter', 'canonical_filter', 'order_by', 'facet_specs', 'dynamic_facet_spec', 'boost_spec', 'query_expansion_spec', 'variant_rollup_keys', 'page_categories', ), + 'search': ('placement', 'visitor_id', 'branch', 'query', 'user_info', 'page_size', 'page_token', 'offset', 'filter', 'canonical_filter', 'order_by', 'facet_specs', 'dynamic_facet_spec', 'boost_spec', 'query_expansion_spec', 'variant_rollup_keys', 'page_categories', 'search_mode', ), 'set_default_branch': ('catalog', 'branch_id', 'note', ), 'set_inventory': ('inventory', 'set_mask', 'set_time', 'allow_missing', ), 'update_catalog': ('catalog', 'update_mask', ),