1// Copyright 2021 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.retail.v2beta; 18 19import "google/api/annotations.proto"; 20import "google/api/client.proto"; 21import "google/api/field_behavior.proto"; 22import "google/api/resource.proto"; 23import "google/cloud/retail/v2beta/common.proto"; 24import "google/cloud/retail/v2beta/product.proto"; 25import "google/protobuf/field_mask.proto"; 26import "google/protobuf/struct.proto"; 27 28option csharp_namespace = "Google.Cloud.Retail.V2Beta"; 29option go_package = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; 30option java_multiple_files = true; 31option java_outer_classname = "SearchServiceProto"; 32option java_package = "com.google.cloud.retail.v2beta"; 33option objc_class_prefix = "RETAIL"; 34option php_namespace = "Google\\Cloud\\Retail\\V2beta"; 35option ruby_package = "Google::Cloud::Retail::V2beta"; 36option (google.api.resource_definition) = { 37 type: "retail.googleapis.com/Experiment" 38 pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}" 39}; 40 41// Service for search. 42// 43// This feature is only available for users who have Retail Search enabled. 44// Enable Retail Search on Cloud Console before using this feature. 45service SearchService { 46 option (google.api.default_host) = "retail.googleapis.com"; 47 option (google.api.oauth_scopes) = 48 "https://www.googleapis.com/auth/cloud-platform"; 49 50 // Performs a search. 51 // 52 // This feature is only available for users who have Retail Search enabled. 53 // Enable Retail Search on Cloud Console before using this feature. 54 rpc Search(SearchRequest) returns (SearchResponse) { 55 option (google.api.http) = { 56 post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" 57 body: "*" 58 additional_bindings { 59 post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search" 60 body: "*" 61 } 62 }; 63 } 64} 65 66// Request message for 67// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] 68// method. 69message SearchRequest { 70 // A facet specification to perform faceted search. 71 message FacetSpec { 72 // Specifies how a facet is computed. 73 message FacetKey { 74 // Required. Supported textual and numerical facet keys in 75 // [Product][google.cloud.retail.v2beta.Product] object, over which the 76 // facet values are computed. Facet key is case-sensitive. 77 // 78 // Allowed facet keys when 79 // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] 80 // is not specified: 81 // 82 // * textual_field = 83 // * "brands" 84 // * "categories" 85 // * "genders" 86 // * "ageGroups" 87 // * "availability" 88 // * "colorFamilies" 89 // * "colors" 90 // * "sizes" 91 // * "materials" 92 // * "patterns" 93 // * "conditions" 94 // * "attributes.key" 95 // * "pickupInStore" 96 // * "shipToStore" 97 // * "sameDayDelivery" 98 // * "nextDayDelivery" 99 // * "customFulfillment1" 100 // * "customFulfillment2" 101 // * "customFulfillment3" 102 // * "customFulfillment4" 103 // * "customFulfillment5" 104 // * "inventory(place_id,attributes.key)" 105 // 106 // * numerical_field = 107 // * "price" 108 // * "discount" 109 // * "rating" 110 // * "ratingCount" 111 // * "attributes.key" 112 // * "inventory(place_id,price)" 113 // * "inventory(place_id,original_price)" 114 // * "inventory(place_id,attributes.key)" 115 string key = 1 [(google.api.field_behavior) = REQUIRED]; 116 117 // Set only if values should be bucketized into intervals. Must be set 118 // for facets with numerical values. Must not be set for facet with text 119 // values. Maximum number of intervals is 40. 120 // 121 // For all numerical facet keys that appear in the list of products from 122 // the catalog, the percentiles 0, 10, 30, 50, 70, 90 and 100 are 123 // computed from their distribution weekly. If the model assigns a high 124 // score to a numerical facet key and its intervals are not specified in 125 // the search request, these percentiles will become the bounds 126 // for its intervals and will be returned in the response. If the 127 // facet key intervals are specified in the request, then the specified 128 // intervals will be returned instead. 129 repeated Interval intervals = 2; 130 131 // Only get facet for the given restricted values. For example, when using 132 // "pickupInStore" as key and set restricted values to 133 // ["store123", "store456"], only facets for "store123" and "store456" are 134 // returned. Only supported on predefined textual fields, custom textual 135 // attributes and fulfillments. Maximum is 20. 136 // 137 // Must be set for the fulfillment facet keys: 138 // 139 // * pickupInStore 140 // 141 // * shipToStore 142 // 143 // * sameDayDelivery 144 // 145 // * nextDayDelivery 146 // 147 // * customFulfillment1 148 // 149 // * customFulfillment2 150 // 151 // * customFulfillment3 152 // 153 // * customFulfillment4 154 // 155 // * customFulfillment5 156 repeated string restricted_values = 3; 157 158 // Only get facet values that start with the given string prefix. For 159 // example, suppose "categories" has three values "Women > Shoe", 160 // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the 161 // "categories" facet will give only "Women > Shoe" and "Women > Dress". 162 // Only supported on textual fields. Maximum is 10. 163 repeated string prefixes = 8; 164 165 // Only get facet values that contains the given strings. For example, 166 // suppose "categories" has three values "Women > Shoe", 167 // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the 168 // "categories" facet will give only "Women > Shoe" and "Men > Shoe". 169 // Only supported on textual fields. Maximum is 10. 170 repeated string contains = 9; 171 172 // True to make facet keys case insensitive when getting faceting 173 // values with prefixes or contains; false otherwise. 174 bool case_insensitive = 10; 175 176 // The order in which 177 // [SearchResponse.Facet.values][google.cloud.retail.v2beta.SearchResponse.Facet.values] 178 // are returned. 179 // 180 // Allowed values are: 181 // 182 // * "count desc", which means order by 183 // [SearchResponse.Facet.values.count][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.count] 184 // descending. 185 // 186 // * "value desc", which means order by 187 // [SearchResponse.Facet.values.value][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.value] 188 // descending. 189 // Only applies to textual facets. 190 // 191 // If not set, textual values are sorted in [natural 192 // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical 193 // intervals are sorted in the order given by 194 // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.intervals]; 195 // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] 196 // are sorted in the order given by 197 // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.restricted_values]. 198 string order_by = 4; 199 200 // The query that is used to compute facet for the given facet key. 201 // When provided, it will override the default behavior of facet 202 // computation. The query syntax is the same as a filter expression. See 203 // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] 204 // for detail syntax and limitations. Notice that there is no limitation 205 // on 206 // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] 207 // when query is specified. 208 // 209 // In the response, 210 // [SearchResponse.Facet.values.value][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.value] 211 // will be always "1" and 212 // [SearchResponse.Facet.values.count][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.count] 213 // will be the number of results that match the query. 214 // 215 // For example, you can set a customized facet for "shipToStore", 216 // where 217 // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] 218 // is "customizedShipToStore", and 219 // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] 220 // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". 221 // Then the facet will count the products that are both in stock and ship 222 // to store "123". 223 string query = 5; 224 225 // Returns the min and max value for each numerical facet intervals. 226 // Ignored for textual facets. 227 bool return_min_max = 11; 228 } 229 230 // Required. The facet key specification. 231 FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; 232 233 // Maximum of facet values that should be returned for this facet. If 234 // unspecified, defaults to 50. The maximum allowed value is 300. Values 235 // above 300 will be coerced to 300. 236 // 237 // If this field is negative, an INVALID_ARGUMENT is returned. 238 int32 limit = 2; 239 240 // List of keys to exclude when faceting. 241 // 242 // 243 // By default, 244 // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] 245 // is not excluded from the filter unless it is listed in this field. 246 // 247 // Listing a facet key in this field allows its values to appear as facet 248 // results, even when they are filtered out of search results. Using this 249 // field does not affect what search results are returned. 250 // 251 // For example, suppose there are 100 products with the color facet "Red" 252 // and 200 products with the color facet "Blue". A query containing the 253 // filter "colorFamilies:ANY("Red")" and having "colorFamilies" as 254 // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] 255 // would by default return only "Red" products in the search results, and 256 // also return "Red" with count 100 as the only color facet. Although there 257 // are also blue products available, "Blue" would not be shown as an 258 // available facet value. 259 // 260 // If "colorFamilies" is listed in "excludedFilterKeys", then the query 261 // returns the facet values "Red" with count 100 and "Blue" with count 262 // 200, because the "colorFamilies" key is now excluded from the filter. 263 // Because this field doesn't affect search results, the search results 264 // are still correctly filtered to return only "Red" products. 265 // 266 // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error 267 // is returned. 268 repeated string excluded_filter_keys = 3; 269 270 // Enables dynamic position for this facet. If set to true, the position of 271 // this facet among all facets in the response is determined by Google 272 // Retail Search. It will be ordered together with dynamic facets if dynamic 273 // facets is enabled. If set to false, the position of this facet in the 274 // response will be the same as in the request, and it will be ranked before 275 // the facets with dynamic position enable and all dynamic facets. 276 // 277 // For example, you may always want to have rating facet returned in 278 // the response, but it's not necessarily to always display the rating facet 279 // at the top. In that case, you can set enable_dynamic_position to true so 280 // that the position of rating facet in response will be determined by 281 // Google Retail Search. 282 // 283 // Another example, assuming you have the following facets in the request: 284 // 285 // * "rating", enable_dynamic_position = true 286 // 287 // * "price", enable_dynamic_position = false 288 // 289 // * "brands", enable_dynamic_position = false 290 // 291 // And also you have a dynamic facets enable, which will generate a facet 292 // 'gender'. Then the final order of the facets in the response can be 293 // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", 294 // "rating") depends on how Google Retail Search orders "gender" and 295 // "rating" facets. However, notice that "price" and "brands" will always be 296 // ranked at 1st and 2nd position since their enable_dynamic_position are 297 // false. 298 bool enable_dynamic_position = 4; 299 } 300 301 // The specifications of dynamically generated facets. 302 message DynamicFacetSpec { 303 // Enum to control DynamicFacet mode 304 enum Mode { 305 // Default value. 306 MODE_UNSPECIFIED = 0; 307 308 // Disable Dynamic Facet. 309 DISABLED = 1; 310 311 // Automatic mode built by Google Retail Search. 312 ENABLED = 2; 313 } 314 315 // Mode of the DynamicFacet feature. 316 // Defaults to 317 // [Mode.DISABLED][google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode.DISABLED] 318 // if it's unset. 319 Mode mode = 1; 320 } 321 322 // Boost specification to boost certain items. 323 message BoostSpec { 324 // Boost applies to products which match a condition. 325 message ConditionBoostSpec { 326 // An expression which specifies a boost condition. The syntax and 327 // supported fields are the same as a filter expression. See 328 // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] 329 // for detail syntax and limitations. 330 // 331 // Examples: 332 // 333 // * To boost products with product ID "product_1" or "product_2", and 334 // color 335 // "Red" or "Blue": 336 // * (id: ANY("product_1", "product_2")) AND (colorFamilies: 337 // ANY("Red","Blue")) 338 string condition = 1; 339 340 // Strength of the condition boost, which should be in [-1, 1]. Negative 341 // boost means demotion. Default is 0.0. 342 // 343 // Setting to 1.0 gives the item a big promotion. However, it does not 344 // necessarily mean that the boosted item will be the top result at all 345 // times, nor that other items will be excluded. Results could still be 346 // shown even when none of them matches the condition. And results that 347 // are significantly more relevant to the search query can still trump 348 // your heavily favored but irrelevant items. 349 // 350 // Setting to -1.0 gives the item a big demotion. However, results that 351 // are deeply relevant might still be shown. The item will have an 352 // upstream battle to get a fairly high ranking, but it is not blocked out 353 // completely. 354 // 355 // Setting to 0.0 means no boost applied. The boosting condition is 356 // ignored. 357 float boost = 2; 358 } 359 360 // Condition boost specifications. If a product matches multiple conditions 361 // in the specifictions, boost scores from these specifications are all 362 // applied and combined in a non-linear way. Maximum number of 363 // specifications is 20. 364 repeated ConditionBoostSpec condition_boost_specs = 1; 365 366 // Whether to skip boostspec validation. If this field is set to true, 367 // invalid 368 // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] 369 // will be ignored and valid 370 // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] 371 // will still be applied. 372 optional bool skip_boost_spec_validation = 2; 373 } 374 375 // Specification to determine under which conditions query expansion should 376 // occur. 377 message QueryExpansionSpec { 378 // Enum describing under which condition query expansion should occur. 379 enum Condition { 380 // Unspecified query expansion condition. In this case, server behavior 381 // defaults to 382 // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. 383 CONDITION_UNSPECIFIED = 0; 384 385 // Disabled query expansion. Only the exact search query is used, even if 386 // [SearchResponse.total_size][google.cloud.retail.v2beta.SearchResponse.total_size] 387 // is zero. 388 DISABLED = 1; 389 390 // Automatic query expansion built by Google Retail Search. 391 AUTO = 3; 392 } 393 394 // The condition under which query expansion should occur. Default to 395 // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. 396 Condition condition = 1; 397 398 // Whether to pin unexpanded results. If this field is set to true, 399 // unexpanded products are always at the top of the search results, followed 400 // by the expanded results. 401 bool pin_unexpanded_results = 2; 402 } 403 404 // The specification for personalization. 405 message PersonalizationSpec { 406 // The personalization mode of each search request. 407 enum Mode { 408 // Default value. In this case, server behavior defaults to 409 // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. 410 MODE_UNSPECIFIED = 0; 411 412 // Let CRS decide whether to use personalization based on quality of user 413 // event data. 414 AUTO = 1; 415 416 // Disable personalization. 417 DISABLED = 2; 418 } 419 420 // Defaults to 421 // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. 422 Mode mode = 1; 423 } 424 425 // The specification for query spell correction. 426 message SpellCorrectionSpec { 427 // Enum describing under which mode spell correction should occur. 428 enum Mode { 429 // Unspecified spell correction mode. In this case, server behavior 430 // defaults to 431 // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. 432 MODE_UNSPECIFIED = 0; 433 434 // Google Retail Search will try to find a spell suggestion if there 435 // is any and put in the 436 // [SearchResponse.corrected_query][google.cloud.retail.v2beta.SearchResponse.corrected_query]. 437 // The spell suggestion will not be used as the search query. 438 SUGGESTION_ONLY = 1; 439 440 // Automatic spell correction built by Google Retail Search. Search will 441 // be based on the corrected query if found. 442 AUTO = 2; 443 } 444 445 // The mode under which spell correction should take effect to 446 // replace the original search query. Default to 447 // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. 448 Mode mode = 1; 449 } 450 451 // The search mode of each search request. 452 enum SearchMode { 453 // Default value. In this case both product search and faceted search will 454 // be performed. Both 455 // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult] 456 // and 457 // [SearchResponse.Facet][google.cloud.retail.v2beta.SearchResponse.Facet] 458 // will be returned. 459 SEARCH_MODE_UNSPECIFIED = 0; 460 461 // Only product search will be performed. The faceted search will be 462 // disabled. 463 // 464 // Only 465 // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult] 466 // will be returned. 467 // [SearchResponse.Facet][google.cloud.retail.v2beta.SearchResponse.Facet] 468 // will not be returned, even if 469 // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] 470 // or 471 // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] 472 // is set. 473 PRODUCT_SEARCH_ONLY = 1; 474 475 // Only faceted search will be performed. The product search will be 476 // disabled. 477 // 478 // When in this mode, one or both of 479 // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] 480 // and 481 // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] 482 // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only 483 // [SearchResponse.Facet][google.cloud.retail.v2beta.SearchResponse.Facet] 484 // will be returned. 485 // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult] 486 // will not be returned. 487 FACETED_SEARCH_ONLY = 2; 488 } 489 490 // Required. The resource name of the Retail Search serving config, such as 491 // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` 492 // or the name of the legacy placement resource, such as 493 // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. 494 // This field is used to identify the serving config name and the set 495 // of models that will be used to make the search. 496 string placement = 1 [(google.api.field_behavior) = REQUIRED]; 497 498 // The branch resource name, such as 499 // `projects/*/locations/global/catalogs/default_catalog/branches/0`. 500 // 501 // Use "default_branch" as the branch ID or leave this field empty, to search 502 // products under the default branch. 503 string branch = 2 [ 504 (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } 505 ]; 506 507 // Raw search query. 508 // 509 // If this field is empty, the request is considered a category browsing 510 // request and returned results are based on 511 // [filter][google.cloud.retail.v2beta.SearchRequest.filter] and 512 // [page_categories][google.cloud.retail.v2beta.SearchRequest.page_categories]. 513 string query = 3; 514 515 // Required. A unique identifier for tracking visitors. For example, this 516 // could be implemented with an HTTP cookie, which should be able to uniquely 517 // identify a visitor on a single device. This unique identifier should not 518 // change if the visitor logs in or out of the website. 519 // 520 // This should be the same identifier as 521 // [UserEvent.visitor_id][google.cloud.retail.v2beta.UserEvent.visitor_id]. 522 // 523 // The field must be a UTF-8 encoded string with a length limit of 128 524 // characters. Otherwise, an INVALID_ARGUMENT error is returned. 525 string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; 526 527 // User information. 528 UserInfo user_info = 5; 529 530 // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return. 531 // If unspecified, defaults to a reasonable value. The maximum allowed value 532 // is 120. Values above 120 will be coerced to 120. 533 // 534 // If this field is negative, an INVALID_ARGUMENT is returned. 535 int32 page_size = 7; 536 537 // A page token 538 // [SearchResponse.next_page_token][google.cloud.retail.v2beta.SearchResponse.next_page_token], 539 // received from a previous 540 // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] 541 // call. Provide this to retrieve the subsequent page. 542 // 543 // When paginating, all other parameters provided to 544 // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] 545 // must match the call that provided the page token. Otherwise, an 546 // INVALID_ARGUMENT error is returned. 547 string page_token = 8; 548 549 // A 0-indexed integer that specifies the current offset (that is, starting 550 // result location, amongst the [Product][google.cloud.retail.v2beta.Product]s 551 // deemed by the API as relevant) in search results. This field is only 552 // considered if 553 // [page_token][google.cloud.retail.v2beta.SearchRequest.page_token] is unset. 554 // 555 // If this field is negative, an INVALID_ARGUMENT is returned. 556 int32 offset = 9; 557 558 // The filter syntax consists of an expression language for constructing a 559 // predicate from one or more fields of the products being filtered. Filter 560 // expression is case-sensitive. See more details at this [user 561 // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). 562 // 563 // If this field is unrecognizable, an INVALID_ARGUMENT is returned. 564 string filter = 10; 565 566 // The default filter that is applied when a user performs a search without 567 // checking any filters on the search page. 568 // 569 // The filter applied to every search request when quality improvement such as 570 // query expansion is needed. For example, if a query does not have enough 571 // results, an expanded query with 572 // [SearchRequest.canonical_filter][google.cloud.retail.v2beta.SearchRequest.canonical_filter] 573 // will be returned as a supplement of the original query. This field is 574 // strongly recommended to achieve high search quality. 575 // 576 // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] 577 // for more details about filter syntax. 578 string canonical_filter = 28; 579 580 // The order in which products are returned. Products can be ordered by 581 // a field in an [Product][google.cloud.retail.v2beta.Product] object. Leave 582 // it unset if ordered by relevance. OrderBy expression is case-sensitive. See 583 // more details at this [user 584 // guide](https://cloud.google.com/retail/docs/filter-and-order#order). 585 // 586 // If this field is unrecognizable, an INVALID_ARGUMENT is returned. 587 string order_by = 11; 588 589 // Facet specifications for faceted search. If empty, no facets are returned. 590 // 591 // A maximum of 200 values are allowed. Otherwise, an INVALID_ARGUMENT error 592 // is returned. 593 repeated FacetSpec facet_specs = 12; 594 595 // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic 596 // to enable dynamic facets. Do not set this field. 597 // 598 // The specification for dynamically generated facets. Notice that only 599 // textual facets can be dynamically generated. 600 DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; 601 602 // Boost specification to boost certain products. See more details at this 603 // [user guide](https://cloud.google.com/retail/docs/boosting). 604 // 605 // Notice that if both 606 // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids] 607 // and 608 // [SearchRequest.boost_spec][google.cloud.retail.v2beta.SearchRequest.boost_spec] 609 // are set, the boost conditions from both places are evaluated. If a search 610 // request matches multiple boost conditions, the final boost score is equal 611 // to the sum of the boost scores from all matched boost conditions. 612 BoostSpec boost_spec = 13; 613 614 // The query expansion specification that specifies the conditions under which 615 // query expansion will occur. See more details at this [user 616 // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). 617 QueryExpansionSpec query_expansion_spec = 14; 618 619 // The keys to fetch and rollup the matching 620 // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] 621 // [Product][google.cloud.retail.v2beta.Product]s attributes, 622 // [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo] or 623 // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s attributes. 624 // The attributes from all the matching 625 // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] 626 // [Product][google.cloud.retail.v2beta.Product]s or 627 // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s are merged and 628 // de-duplicated. Notice that rollup attributes will lead to extra query 629 // latency. Maximum number of keys is 30. 630 // 631 // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], a 632 // fulfillment type and a fulfillment ID must be provided in the format of 633 // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", 634 // "pickupInStore" is fulfillment type and "store123" is the store ID. 635 // 636 // Supported keys are: 637 // 638 // * colorFamilies 639 // * price 640 // * originalPrice 641 // * discount 642 // * variantId 643 // * inventory(place_id,price) 644 // * inventory(place_id,original_price) 645 // * inventory(place_id,attributes.key), where key is any key in the 646 // [Product.local_inventories.attributes][google.cloud.retail.v2beta.LocalInventory.attributes] 647 // map. 648 // * attributes.key, where key is any key in the 649 // [Product.attributes][google.cloud.retail.v2beta.Product.attributes] map. 650 // * pickupInStore.id, where id is any 651 // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] 652 // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] 653 // "pickup-in-store". 654 // * shipToStore.id, where id is any 655 // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] 656 // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] 657 // "ship-to-store". 658 // * sameDayDelivery.id, where id is any 659 // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] 660 // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] 661 // "same-day-delivery". 662 // * nextDayDelivery.id, where id is any 663 // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] 664 // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] 665 // "next-day-delivery". 666 // * customFulfillment1.id, where id is any 667 // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] 668 // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] 669 // "custom-type-1". 670 // * customFulfillment2.id, where id is any 671 // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] 672 // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] 673 // "custom-type-2". 674 // * customFulfillment3.id, where id is any 675 // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] 676 // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] 677 // "custom-type-3". 678 // * customFulfillment4.id, where id is any 679 // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] 680 // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] 681 // "custom-type-4". 682 // * customFulfillment5.id, where id is any 683 // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] 684 // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] 685 // "custom-type-5". 686 // 687 // If this field is set to an invalid value other than these, an 688 // INVALID_ARGUMENT error is returned. 689 repeated string variant_rollup_keys = 17; 690 691 // The categories associated with a category page. Must be set for category 692 // navigation queries to achieve good search quality. The format should be 693 // the same as 694 // [UserEvent.page_categories][google.cloud.retail.v2beta.UserEvent.page_categories]; 695 // 696 // To represent full path of category, use '>' sign to separate different 697 // hierarchies. If '>' is part of the category name, replace it with 698 // other character(s). 699 // 700 // Category pages include special pages such as sales or promotions. For 701 // instance, a special sale page may have the category hierarchy: 702 // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. 703 repeated string page_categories = 23; 704 705 // The search mode of the search request. If not specified, a single search 706 // request triggers both product search and faceted search. 707 SearchMode search_mode = 31; 708 709 // The specification for personalization. 710 // 711 // Notice that if both 712 // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec] 713 // and 714 // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] 715 // are set. 716 // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] 717 // will override 718 // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec]. 719 PersonalizationSpec personalization_spec = 32; 720 721 // The labels applied to a resource must meet the following requirements: 722 // 723 // * Each resource can have multiple labels, up to a maximum of 64. 724 // * Each label must be a key-value pair. 725 // * Keys have a minimum length of 1 character and a maximum length of 63 726 // characters and cannot be empty. Values can be empty and have a maximum 727 // length of 63 characters. 728 // * Keys and values can contain only lowercase letters, numeric characters, 729 // underscores, and dashes. All characters must use UTF-8 encoding, and 730 // international characters are allowed. 731 // * The key portion of a label must be unique. However, you can use the same 732 // key with multiple resources. 733 // * Keys must start with a lowercase letter or international character. 734 // 735 // See [Google Cloud 736 // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) 737 // for more details. 738 map<string, string> labels = 34; 739 740 // The spell correction specification that specifies the mode under 741 // which spell correction will take effect. 742 optional SpellCorrectionSpec spell_correction_spec = 35; 743 744 // The entity for customers that may run multiple different entities, domains, 745 // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, 746 // `google.com`, `youtube.com`, etc. 747 // If this is set, it should be exactly matched with 748 // [UserEvent.entity][google.cloud.retail.v2beta.UserEvent.entity] to get 749 // search results boosted by entity. 750 string entity = 38; 751} 752 753// Response message for 754// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] 755// method. 756message SearchResponse { 757 // Represents the search results. 758 message SearchResult { 759 // [Product.id][google.cloud.retail.v2beta.Product.id] of the searched 760 // [Product][google.cloud.retail.v2beta.Product]. 761 string id = 1; 762 763 // The product data snippet in the search response. Only 764 // [Product.name][google.cloud.retail.v2beta.Product.name] is guaranteed to 765 // be populated. 766 // 767 // [Product.variants][google.cloud.retail.v2beta.Product.variants] contains 768 // the product variants that match the search query. If there are multiple 769 // product variants matching the query, top 5 most relevant product variants 770 // are returned and ordered by relevancy. 771 // 772 // If relevancy can be deternmined, use 773 // [matching_variant_fields][google.cloud.retail.v2beta.SearchResponse.SearchResult.matching_variant_fields] 774 // to look up matched product variants fields. If relevancy cannot be 775 // determined, e.g. when searching "shoe" all products in a shoe product can 776 // be a match, 5 product variants are returned but order is meaningless. 777 Product product = 2; 778 779 // The count of matched 780 // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] 781 // [Product][google.cloud.retail.v2beta.Product]s. 782 int32 matching_variant_count = 3; 783 784 // If a [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] 785 // [Product][google.cloud.retail.v2beta.Product] matches the search query, 786 // this map indicates which [Product][google.cloud.retail.v2beta.Product] 787 // fields are matched. The key is the 788 // [Product.name][google.cloud.retail.v2beta.Product.name], the value is a 789 // field mask of the matched [Product][google.cloud.retail.v2beta.Product] 790 // fields. If matched attributes cannot be determined, this map will be 791 // empty. 792 // 793 // For example, a key "sku1" with field mask 794 // "products.color_info" indicates there is a match between 795 // "sku1" [ColorInfo][google.cloud.retail.v2beta.ColorInfo] and the query. 796 map<string, google.protobuf.FieldMask> matching_variant_fields = 4; 797 798 // The rollup matching 799 // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] 800 // [Product][google.cloud.retail.v2beta.Product] attributes. The key is one 801 // of the 802 // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2beta.SearchRequest.variant_rollup_keys]. 803 // The values are the merged and de-duplicated 804 // [Product][google.cloud.retail.v2beta.Product] attributes. Notice that the 805 // rollup values are respect filter. For example, when filtering by 806 // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is 807 // returned. 808 // 809 // For textual and numerical attributes, the rollup values is a list of 810 // string or double values with type 811 // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if 812 // there are two variants with colors "red" and "blue", the rollup values 813 // are 814 // 815 // { key: "colorFamilies" 816 // value { 817 // list_value { 818 // values { string_value: "red" } 819 // values { string_value: "blue" } 820 // } 821 // } 822 // } 823 // 824 // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], the 825 // rollup values is a double value with type 826 // [google.protobuf.Value][google.protobuf.Value]. For example, 827 // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there 828 // are 10 variants in this product are available in the store "store1". 829 map<string, google.protobuf.Value> variant_rollup_values = 5; 830 831 // Specifies previous events related to this product for this user based on 832 // [UserEvent][google.cloud.retail.v2beta.UserEvent] with same 833 // [SearchRequest.visitor_id][google.cloud.retail.v2beta.SearchRequest.visitor_id] 834 // or [UserInfo.user_id][google.cloud.retail.v2beta.UserInfo.user_id]. 835 // 836 // This is set only when 837 // [SearchRequest.PersonalizationSpec.mode][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.mode] 838 // is 839 // [SearchRequest.PersonalizationSpec.Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. 840 // 841 // Possible values: 842 // 843 // * `purchased`: Indicates that this product has been purchased before. 844 repeated string personal_labels = 7; 845 } 846 847 // A facet result. 848 message Facet { 849 // A facet value which contains value names and their count. 850 message FacetValue { 851 // A facet value which contains values. 852 oneof facet_value { 853 // Text value of a facet, such as "Black" for facet "colorFamilies". 854 string value = 1; 855 856 // Interval value for a facet, such as [10, 20) for facet "price". 857 Interval interval = 2; 858 } 859 860 // Number of items that have this facet value. 861 int64 count = 3; 862 863 // The minimum value in the 864 // [FacetValue.interval][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.interval]. 865 // Only supported on numerical facets and returned if 866 // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.return_min_max] 867 // is true. 868 double min_value = 5; 869 870 // The maximum value in the 871 // [FacetValue.interval][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.interval]. 872 // Only supported on numerical facets and returned if 873 // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.return_min_max] 874 // is true. 875 double max_value = 6; 876 } 877 878 // The key for this facet. E.g., "colorFamilies" or "price" or 879 // "attributes.attr1". 880 string key = 1; 881 882 // The facet values for this field. 883 repeated FacetValue values = 2; 884 885 // Whether the facet is dynamically generated. 886 bool dynamic_facet = 3; 887 } 888 889 // Information describing query expansion including whether expansion has 890 // occurred. 891 message QueryExpansionInfo { 892 // Bool describing whether query expansion has occurred. 893 bool expanded_query = 1; 894 895 // Number of pinned results. This field will only be set when expansion 896 // happens and 897 // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] 898 // is set to true. 899 int64 pinned_result_count = 2; 900 } 901 902 // A list of matched items. The order represents the ranking. 903 repeated SearchResult results = 1; 904 905 // Results of facets requested by user. 906 repeated Facet facets = 2; 907 908 // The estimated total count of matched items irrespective of pagination. The 909 // count of [results][google.cloud.retail.v2beta.SearchResponse.results] 910 // returned by pagination may be less than the 911 // [total_size][google.cloud.retail.v2beta.SearchResponse.total_size] that 912 // matches. 913 int32 total_size = 3; 914 915 // Contains the spell corrected query, if found. If the spell correction type 916 // is AUTOMATIC, then the search results are based on corrected_query. 917 // Otherwise the original query is used for search. 918 string corrected_query = 4; 919 920 // A unique search token. This should be included in the 921 // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this 922 // search, which enables accurate attribution of search model performance. 923 string attribution_token = 5; 924 925 // A token that can be sent as 926 // [SearchRequest.page_token][google.cloud.retail.v2beta.SearchRequest.page_token] 927 // to retrieve the next page. If this field is omitted, there are no 928 // subsequent pages. 929 string next_page_token = 6; 930 931 // Query expansion information for the returned results. 932 QueryExpansionInfo query_expansion_info = 7; 933 934 // The URI of a customer-defined redirect page. If redirect action is 935 // triggered, no search is performed, and only 936 // [redirect_uri][google.cloud.retail.v2beta.SearchResponse.redirect_uri] and 937 // [attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] 938 // are set in the response. 939 string redirect_uri = 10; 940 941 // The fully qualified resource name of applied 942 // [controls](https://cloud.google.com/retail/docs/serving-control-rules). 943 repeated string applied_controls = 12; 944 945 // The invalid 946 // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] 947 // that are not applied during serving. 948 repeated SearchRequest.BoostSpec.ConditionBoostSpec 949 invalid_condition_boost_specs = 14; 950 951 // Metadata related to A/B testing [Experiment][] associated with this 952 // response. Only exists when an experiment is triggered. 953 repeated ExperimentInfo experiment_info = 17; 954} 955 956// Metadata for active A/B testing [Experiments][]. 957message ExperimentInfo { 958 // Metadata for active serving config A/B tests. 959 message ServingConfigExperiment { 960 // The fully qualified resource name of the original 961 // [SearchRequest.placement][google.cloud.retail.v2beta.SearchRequest.placement] 962 // in the search request prior to reassignment by experiment API. For 963 // example: `projects/*/locations/*/catalogs/*/servingConfigs/*`. 964 string original_serving_config = 1 [(google.api.resource_reference) = { 965 type: "retail.googleapis.com/ServingConfig" 966 }]; 967 968 // The fully qualified resource name of the serving config 969 // [VariantArm.serving_config_id][] responsible for generating the search 970 // response. For example: 971 // `projects/*/locations/*/catalogs/*/servingConfigs/*`. 972 string experiment_serving_config = 2 [(google.api.resource_reference) = { 973 type: "retail.googleapis.com/ServingConfig" 974 }]; 975 } 976 977 // Information associated with the specific experiment entity being recorded. 978 oneof experiment_metadata { 979 // A/B test between existing Cloud Retail Search 980 // [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s. 981 ServingConfigExperiment serving_config_experiment = 2; 982 } 983 984 // The fully qualified resource name of the experiment that provides the 985 // serving config under test, should an active experiment exist. For example: 986 // `projects/*/locations/global/catalogs/default_catalog/experiments/experiment_id` 987 string experiment = 1 [(google.api.resource_reference) = { 988 type: "retail.googleapis.com/Experiment" 989 }]; 990} 991