Skip to content

Commit d2835e8

Browse files
Google APIscopybara-github
authored andcommitted
feat: add a user_attributes field in SearchRequest that can be used for personalization
feat: add a model_scores field in SearchResponse.results to expose model quality signals PiperOrigin-RevId: 775377248
1 parent fc1e32c commit d2835e8

File tree

6 files changed

+71
-47
lines changed

6 files changed

+71
-47
lines changed

google/cloud/retail/v2/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ load(
398398

399399
csharp_proto_library(
400400
name = "retail_csharp_proto",
401-
extra_opts = [],
402401
deps = [":retail_proto"],
403402
)
404403

google/cloud/retail/v2/catalog_service.proto

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -59,39 +59,39 @@ service CatalogService {
5959
}
6060

6161
// Set a specified branch id as default branch. API methods such as
62-
// [SearchService.Search][google.cloud.retail.v2.SearchService.Search],
63-
// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct],
64-
// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]
65-
// will treat requests using "default_branch" to the actual branch id set as
66-
// default.
62+
// [SearchService.Search][google.cloud.retail.v2.SearchService.Search],
63+
// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct],
64+
// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]
65+
// will treat requests using "default_branch" to the actual branch id set as
66+
// default.
6767
//
68-
// For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as
69-
// default, setting
70-
// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
71-
// `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent
72-
// to setting
73-
// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
74-
// `projects/*/locations/*/catalogs/*/branches/1`.
68+
// For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as
69+
// default, setting
70+
// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
71+
// `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent
72+
// to setting
73+
// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
74+
// `projects/*/locations/*/catalogs/*/branches/1`.
7575
//
76-
// Using multiple branches can be useful when developers would like
77-
// to have a staging branch to test and verify for future usage. When it
78-
// becomes ready, developers switch on the staging branch using this API
79-
// while keeping using
80-
// `projects/*/locations/*/catalogs/*/branches/default_branch` as
81-
// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
82-
// route the traffic to this staging branch.
76+
// Using multiple branches can be useful when developers would like
77+
// to have a staging branch to test and verify for future usage. When it
78+
// becomes ready, developers switch on the staging branch using this API
79+
// while keeping using
80+
// `projects/*/locations/*/catalogs/*/branches/default_branch` as
81+
// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
82+
// route the traffic to this staging branch.
8383
//
84-
// CAUTION: If you have live predict/search traffic, switching the default
85-
// branch could potentially cause outages if the ID space of the new branch
86-
// is very different from the old one.
84+
// CAUTION: If you have live predict/search traffic, switching the default
85+
// branch could potentially cause outages if the ID space of the new branch
86+
// is very different from the old one.
8787
//
88-
// More specifically:
88+
// More specifically:
8989
//
90-
// * PredictionService will only return product IDs from branch {newBranch}.
91-
// * SearchService will only return product IDs from branch {newBranch}
92-
// (if branch is not explicitly set).
93-
// * UserEventService will only join events with products from branch
94-
// {newBranch}.
90+
// * PredictionService will only return product IDs from branch {newBranch}.
91+
// * SearchService will only return product IDs from branch {newBranch}
92+
// (if branch is not explicitly set).
93+
// * UserEventService will only join events with products from branch
94+
// {newBranch}.
9595
rpc SetDefaultBranch(SetDefaultBranchRequest)
9696
returns (google.protobuf.Empty) {
9797
option (google.api.http) = {
@@ -102,8 +102,8 @@ service CatalogService {
102102
}
103103

104104
// Get which branch is currently default branch set by
105-
// [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch]
106-
// method under a specified parent catalog.
105+
// [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch]
106+
// method under a specified parent catalog.
107107
rpc GetDefaultBranch(GetDefaultBranchRequest)
108108
returns (GetDefaultBranchResponse) {
109109
option (google.api.http) = {

google/cloud/retail/v2/common.proto

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,3 +932,15 @@ message PinControlMetadata {
932932
// keyed by pin position.
933933
map<int64, ProductPins> dropped_pins = 2;
934934
}
935+
936+
// A list of string values.
937+
message StringList {
938+
// String values.
939+
repeated string values = 1;
940+
}
941+
942+
// A message with a list of double values.
943+
message DoubleList {
944+
// The list of double values.
945+
repeated double values = 1;
946+
}

google/cloud/retail/v2/retail_v2.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ documentation:
5454
Recommendations. These discovery AI solutions help you implement
5555
personalized search, browse and recommendations, based on machine learning
5656
models, across your websites and mobile applications.
57-
rules:
58-
- selector: google.cloud.location.Locations.GetLocation
59-
description: Gets information about a location.
60-
61-
- selector: google.cloud.location.Locations.ListLocations
62-
description: Lists information about the supported locations for this service.
6357
6458
http:
6559
rules:
@@ -77,14 +71,6 @@ http:
7771

7872
authentication:
7973
rules:
80-
- selector: google.cloud.location.Locations.GetLocation
81-
oauth:
82-
canonical_scopes: |-
83-
https://www.googleapis.com/auth/cloud-platform
84-
- selector: google.cloud.location.Locations.ListLocations
85-
oauth:
86-
canonical_scopes: |-
87-
https://www.googleapis.com/auth/cloud-platform
8874
- selector: google.cloud.retail.v2.AnalyticsService.ExportAnalyticsMetrics
8975
oauth:
9076
canonical_scopes: |-

google/cloud/retail/v2/search_service.proto

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ message SearchRequest {
429429
// [Condition.DISABLED][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition.DISABLED].
430430
Condition condition = 1;
431431

432-
// Whether to pin unexpanded results. If this field is set to true,
432+
// Whether to pin unexpanded results. The default value is false. If this
433+
// field is set to true,
433434
// unexpanded products are always at the top of the search results, followed
434435
// by the expanded results.
435436
bool pin_unexpanded_results = 2;
@@ -879,6 +880,29 @@ message SearchRequest {
879880
// [LocalInventory.place_id][google.cloud.retail.v2.LocalInventory.place_id]
880881
// for revenue optimization.
881882
string place_id = 46 [(google.api.field_behavior) = OPTIONAL];
883+
884+
// Optional. The user attributes that could be used for personalization of
885+
// search results.
886+
// * Populate at most 100 key-value pairs per query.
887+
// * Only supports string keys and repeated string values.
888+
// * Duplcate keys are not allowed within a single query.
889+
//
890+
// Example:
891+
// user_attributes: [
892+
// { key: "pets"
893+
// value {
894+
// values: "dog"
895+
// values: "cat"
896+
// }
897+
// },
898+
// { key: "state"
899+
// value {
900+
// values: "CA"
901+
// }
902+
// }
903+
// ]
904+
map<string, StringList> user_attributes = 47
905+
[(google.api.field_behavior) = OPTIONAL];
882906
}
883907

884908
// Response message for
@@ -971,6 +995,9 @@ message SearchResponse {
971995
//
972996
// * `purchased`: Indicates that this product has been purchased before.
973997
repeated string personal_labels = 7;
998+
999+
// Google provided available scores.
1000+
map<string, DoubleList> model_scores = 8;
9741001
}
9751002

9761003
// A facet result.

google/cloud/retail/v2/user_event.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ message UserEvent {
7070
// 128 bytes. A session is an aggregation of an end user behavior in a time
7171
// span.
7272
//
73-
// A general guideline to populate the sesion_id:
73+
// A general guideline to populate the session_id:
7474
// 1. If user has no activity for 30 min, a new session_id should be assigned.
7575
// 2. The session_id should be unique across users, suggest use uuid or add
7676
// visitor_id as prefix.

0 commit comments

Comments
 (0)