• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.v2alpha;
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/v2alpha/common.proto";
24import "google/cloud/retail/v2alpha/product.proto";
25import "google/protobuf/field_mask.proto";
26import "google/protobuf/struct.proto";
27
28option csharp_namespace = "Google.Cloud.Retail.V2Alpha";
29option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb";
30option java_multiple_files = true;
31option java_outer_classname = "SearchServiceProto";
32option java_package = "com.google.cloud.retail.v2alpha";
33option objc_class_prefix = "RETAIL";
34option php_namespace = "Google\\Cloud\\Retail\\V2alpha";
35option ruby_package = "Google::Cloud::Retail::V2alpha";
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: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:search"
57      body: "*"
58      additional_bindings {
59        post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search"
60        body: "*"
61      }
62    };
63  }
64}
65
66// Request message for
67// [SearchService.Search][google.cloud.retail.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.SearchResponse.Facet.FacetValue.count]
184      // descending.
185      //
186      // * "value desc", which means order by
187      // [SearchResponse.Facet.values.value][google.cloud.retail.v2alpha.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.v2alpha.SearchRequest.FacetSpec.FacetKey.intervals];
195      // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]
196      // are sorted in the order given by
197      // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2alpha.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.v2alpha.SearchRequest.filter]
204      // for detail syntax and limitations. Notice that there is no limitation
205      // on
206      // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key]
207      // when query is specified.
208      //
209      // In the response,
210      // [SearchResponse.Facet.values.value][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.value]
211      // will be always "1" and
212      // [SearchResponse.Facet.values.count][google.cloud.retail.v2alpha.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.v2alpha.SearchRequest.FacetSpec.FacetKey.key]
218      // is "customizedShipToStore", and
219      // [FacetKey.query][google.cloud.retail.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.SearchRequest.BoostSpec.condition_boost_specs]
369    // will be ignored and valid
370    // [BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.SearchRequest.SpellCorrectionSpec.Mode.AUTO].
448    Mode mode = 1;
449  }
450
451  // The relevance threshold of the search results. The higher relevance
452  // threshold is, the higher relevant results are shown and the less number of
453  // results are returned.
454  enum RelevanceThreshold {
455    // Default value. In this case, server behavior defaults to
456    // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH].
457    RELEVANCE_THRESHOLD_UNSPECIFIED = 0;
458
459    // High relevance threshold.
460    HIGH = 1;
461
462    // Medium relevance threshold.
463    MEDIUM = 2;
464
465    // Low relevance threshold.
466    LOW = 3;
467
468    // Lowest relevance threshold.
469    LOWEST = 4;
470  }
471
472  // The search mode of each search request.
473  enum SearchMode {
474    // Default value. In this case both product search and faceted search will
475    // be performed. Both
476    // [SearchResponse.SearchResult][google.cloud.retail.v2alpha.SearchResponse.SearchResult]
477    // and
478    // [SearchResponse.Facet][google.cloud.retail.v2alpha.SearchResponse.Facet]
479    // will be returned.
480    SEARCH_MODE_UNSPECIFIED = 0;
481
482    // Only product search will be performed. The faceted search will be
483    // disabled.
484    //
485    // Only
486    // [SearchResponse.SearchResult][google.cloud.retail.v2alpha.SearchResponse.SearchResult]
487    // will be returned.
488    // [SearchResponse.Facet][google.cloud.retail.v2alpha.SearchResponse.Facet]
489    // will not be returned, even if
490    // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs]
491    // or
492    // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec]
493    // is set.
494    PRODUCT_SEARCH_ONLY = 1;
495
496    // Only faceted search will be performed. The product search will be
497    // disabled.
498    //
499    // When in this mode, one or both of
500    // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs]
501    // and
502    // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec]
503    // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only
504    // [SearchResponse.Facet][google.cloud.retail.v2alpha.SearchResponse.Facet]
505    // will be returned.
506    // [SearchResponse.SearchResult][google.cloud.retail.v2alpha.SearchResponse.SearchResult]
507    // will not be returned.
508    FACETED_SEARCH_ONLY = 2;
509  }
510
511  // Required. The resource name of the Retail Search serving config, such as
512  // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config`
513  // or the name of the legacy placement resource, such as
514  // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`.
515  // This field is used to identify the serving config name and the set
516  // of models that will be used to make the search.
517  string placement = 1 [(google.api.field_behavior) = REQUIRED];
518
519  // The branch resource name, such as
520  // `projects/*/locations/global/catalogs/default_catalog/branches/0`.
521  //
522  // Use "default_branch" as the branch ID or leave this field empty, to search
523  // products under the default branch.
524  string branch = 2 [
525    (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" }
526  ];
527
528  // Raw search query.
529  //
530  // If this field is empty, the request is considered a category browsing
531  // request and returned results are based on
532  // [filter][google.cloud.retail.v2alpha.SearchRequest.filter] and
533  // [page_categories][google.cloud.retail.v2alpha.SearchRequest.page_categories].
534  string query = 3;
535
536  // Required. A unique identifier for tracking visitors. For example, this
537  // could be implemented with an HTTP cookie, which should be able to uniquely
538  // identify a visitor on a single device. This unique identifier should not
539  // change if the visitor logs in or out of the website.
540  //
541  // This should be the same identifier as
542  // [UserEvent.visitor_id][google.cloud.retail.v2alpha.UserEvent.visitor_id].
543  //
544  // The field must be a UTF-8 encoded string with a length limit of 128
545  // characters. Otherwise, an INVALID_ARGUMENT error is returned.
546  string visitor_id = 4 [(google.api.field_behavior) = REQUIRED];
547
548  // User information.
549  UserInfo user_info = 5;
550
551  // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to
552  // return. If unspecified, defaults to a reasonable value. The maximum allowed
553  // value is 120. Values above 120 will be coerced to 120.
554  //
555  // If this field is negative, an INVALID_ARGUMENT is returned.
556  int32 page_size = 7;
557
558  // A page token
559  // [SearchResponse.next_page_token][google.cloud.retail.v2alpha.SearchResponse.next_page_token],
560  // received from a previous
561  // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]
562  // call. Provide this to retrieve the subsequent page.
563  //
564  // When paginating, all other parameters provided to
565  // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]
566  // must match the call that provided the page token. Otherwise, an
567  // INVALID_ARGUMENT error is returned.
568  string page_token = 8;
569
570  // A 0-indexed integer that specifies the current offset (that is, starting
571  // result location, amongst the
572  // [Product][google.cloud.retail.v2alpha.Product]s deemed by the API as
573  // relevant) in search results. This field is only considered if
574  // [page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] is
575  // unset.
576  //
577  // If this field is negative, an INVALID_ARGUMENT is returned.
578  int32 offset = 9;
579
580  // The filter syntax consists of an expression language for constructing a
581  // predicate from one or more fields of the products being filtered. Filter
582  // expression is case-sensitive. See more details at this [user
583  // guide](https://cloud.google.com/retail/docs/filter-and-order#filter).
584  //
585  // If this field is unrecognizable, an INVALID_ARGUMENT is returned.
586  string filter = 10;
587
588  // The default filter that is applied when a user performs a search without
589  // checking any filters on the search page.
590  //
591  // The filter applied to every search request when quality improvement such as
592  // query expansion is needed. For example, if a query does not have enough
593  // results, an expanded query with
594  // [SearchRequest.canonical_filter][google.cloud.retail.v2alpha.SearchRequest.canonical_filter]
595  // will be returned as a supplement of the original query. This field is
596  // strongly recommended to achieve high search quality.
597  //
598  // See
599  // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter]
600  // for more details about filter syntax.
601  string canonical_filter = 28;
602
603  // The order in which products are returned. Products can be ordered by
604  // a field in an [Product][google.cloud.retail.v2alpha.Product] object. Leave
605  // it unset if ordered by relevance. OrderBy expression is case-sensitive. See
606  // more details at this [user
607  // guide](https://cloud.google.com/retail/docs/filter-and-order#order).
608  //
609  // If this field is unrecognizable, an INVALID_ARGUMENT is returned.
610  string order_by = 11;
611
612  // Facet specifications for faceted search. If empty, no facets are returned.
613  //
614  // A maximum of 200 values are allowed. Otherwise, an INVALID_ARGUMENT error
615  // is returned.
616  repeated FacetSpec facet_specs = 12;
617
618  // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic
619  // to enable dynamic facets. Do not set this field.
620  //
621  // The specification for dynamically generated facets. Notice that only
622  // textual facets can be dynamically generated.
623  DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true];
624
625  // Boost specification to boost certain products. See more details at this
626  // [user guide](https://cloud.google.com/retail/docs/boosting).
627  //
628  // Notice that if both
629  // [ServingConfig.boost_control_ids][google.cloud.retail.v2alpha.ServingConfig.boost_control_ids]
630  // and
631  // [SearchRequest.boost_spec][google.cloud.retail.v2alpha.SearchRequest.boost_spec]
632  // are set, the boost conditions from both places are evaluated. If a search
633  // request matches multiple boost conditions, the final boost score is equal
634  // to the sum of the boost scores from all matched boost conditions.
635  BoostSpec boost_spec = 13;
636
637  // The query expansion specification that specifies the conditions under which
638  // query expansion will occur. See more details at this [user
639  // guide](https://cloud.google.com/retail/docs/result-size#query_expansion).
640  QueryExpansionSpec query_expansion_spec = 14;
641
642  // The relevance threshold of the search results.
643  //
644  // Defaults to
645  // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH],
646  // which means only the most relevant results are shown, and the least number
647  // of results are returned. See more details at this [user
648  // guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding).
649  RelevanceThreshold relevance_threshold = 15;
650
651  // The keys to fetch and rollup the matching
652  // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT]
653  // [Product][google.cloud.retail.v2alpha.Product]s attributes,
654  // [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo] or
655  // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s attributes.
656  // The attributes from all the matching
657  // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT]
658  // [Product][google.cloud.retail.v2alpha.Product]s or
659  // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s are merged
660  // and de-duplicated. Notice that rollup attributes will lead to extra query
661  // latency. Maximum number of keys is 30.
662  //
663  // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], a
664  // fulfillment type and a fulfillment ID must be provided in the format of
665  // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123",
666  // "pickupInStore" is fulfillment type and "store123" is the store ID.
667  //
668  // Supported keys are:
669  //
670  // * colorFamilies
671  // * price
672  // * originalPrice
673  // * discount
674  // * variantId
675  // * inventory(place_id,price)
676  // * inventory(place_id,original_price)
677  // * inventory(place_id,attributes.key), where key is any key in the
678  //   [Product.local_inventories.attributes][google.cloud.retail.v2alpha.LocalInventory.attributes]
679  //   map.
680  // * attributes.key, where key is any key in the
681  //   [Product.attributes][google.cloud.retail.v2alpha.Product.attributes] map.
682  // * pickupInStore.id, where id is any
683  // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]
684  // for
685  // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]
686  //   "pickup-in-store".
687  // * shipToStore.id, where id is any
688  // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]
689  // for
690  // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]
691  //   "ship-to-store".
692  // * sameDayDelivery.id, where id is any
693  // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]
694  // for
695  // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]
696  //   "same-day-delivery".
697  // * nextDayDelivery.id, where id is any
698  // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]
699  // for
700  // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]
701  //   "next-day-delivery".
702  // * customFulfillment1.id, where id is any
703  // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]
704  // for
705  // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]
706  //   "custom-type-1".
707  // * customFulfillment2.id, where id is any
708  // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]
709  // for
710  // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]
711  //   "custom-type-2".
712  // * customFulfillment3.id, where id is any
713  // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]
714  // for
715  // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]
716  //   "custom-type-3".
717  // * customFulfillment4.id, where id is any
718  // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]
719  // for
720  // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]
721  //   "custom-type-4".
722  // * customFulfillment5.id, where id is any
723  // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]
724  // for
725  // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]
726  //   "custom-type-5".
727  //
728  // If this field is set to an invalid value other than these, an
729  // INVALID_ARGUMENT error is returned.
730  repeated string variant_rollup_keys = 17;
731
732  // The categories associated with a category page. Must be set for category
733  // navigation queries to achieve good search quality. The format should be
734  // the same as
735  // [UserEvent.page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories];
736  //
737  // To represent full path of category, use '>' sign to separate different
738  // hierarchies. If '>' is part of the category name, replace it with
739  // other character(s).
740  //
741  // Category pages include special pages such as sales or promotions. For
742  // instance, a special sale page may have the category hierarchy:
743  // "pageCategories" : ["Sales > 2017 Black Friday Deals"].
744  repeated string page_categories = 23;
745
746  // The search mode of the search request. If not specified, a single search
747  // request triggers both product search and faceted search.
748  SearchMode search_mode = 31;
749
750  // The specification for personalization.
751  //
752  // Notice that if both
753  // [ServingConfig.personalization_spec][google.cloud.retail.v2alpha.ServingConfig.personalization_spec]
754  // and
755  // [SearchRequest.personalization_spec][google.cloud.retail.v2alpha.SearchRequest.personalization_spec]
756  // are set.
757  // [SearchRequest.personalization_spec][google.cloud.retail.v2alpha.SearchRequest.personalization_spec]
758  // will override
759  // [ServingConfig.personalization_spec][google.cloud.retail.v2alpha.ServingConfig.personalization_spec].
760  PersonalizationSpec personalization_spec = 32;
761
762  // The labels applied to a resource must meet the following requirements:
763  //
764  // * Each resource can have multiple labels, up to a maximum of 64.
765  // * Each label must be a key-value pair.
766  // * Keys have a minimum length of 1 character and a maximum length of 63
767  //   characters and cannot be empty. Values can be empty and have a maximum
768  //   length of 63 characters.
769  // * Keys and values can contain only lowercase letters, numeric characters,
770  //   underscores, and dashes. All characters must use UTF-8 encoding, and
771  //   international characters are allowed.
772  // * The key portion of a label must be unique. However, you can use the same
773  //   key with multiple resources.
774  // * Keys must start with a lowercase letter or international character.
775  //
776  // See [Google Cloud
777  // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
778  // for more details.
779  map<string, string> labels = 34;
780
781  // The spell correction specification that specifies the mode under
782  // which spell correction will take effect.
783  optional SpellCorrectionSpec spell_correction_spec = 35;
784
785  // The entity for customers that may run multiple different entities, domains,
786  // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`,
787  // `google.com`, `youtube.com`, etc.
788  // If this is set, it should be exactly matched with
789  // [UserEvent.entity][google.cloud.retail.v2alpha.UserEvent.entity] to get
790  // search results boosted by entity.
791  string entity = 38;
792}
793
794// Response message for
795// [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]
796// method.
797message SearchResponse {
798  // Represents the search results.
799  message SearchResult {
800    // [Product.id][google.cloud.retail.v2alpha.Product.id] of the searched
801    // [Product][google.cloud.retail.v2alpha.Product].
802    string id = 1;
803
804    // The product data snippet in the search response. Only
805    // [Product.name][google.cloud.retail.v2alpha.Product.name] is guaranteed to
806    // be populated.
807    //
808    // [Product.variants][google.cloud.retail.v2alpha.Product.variants] contains
809    // the product variants that match the search query. If there are multiple
810    // product variants matching the query, top 5 most relevant product variants
811    // are returned and ordered by relevancy.
812    //
813    // If relevancy can be deternmined, use
814    // [matching_variant_fields][google.cloud.retail.v2alpha.SearchResponse.SearchResult.matching_variant_fields]
815    // to look up matched product variants fields. If relevancy cannot be
816    // determined, e.g. when searching "shoe" all products in a shoe product can
817    // be a match, 5 product variants are returned but order is meaningless.
818    Product product = 2;
819
820    // The count of matched
821    // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT]
822    // [Product][google.cloud.retail.v2alpha.Product]s.
823    int32 matching_variant_count = 3;
824
825    // If a [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT]
826    // [Product][google.cloud.retail.v2alpha.Product] matches the search query,
827    // this map indicates which [Product][google.cloud.retail.v2alpha.Product]
828    // fields are matched. The key is the
829    // [Product.name][google.cloud.retail.v2alpha.Product.name], the value is a
830    // field mask of the matched [Product][google.cloud.retail.v2alpha.Product]
831    // fields. If matched attributes cannot be determined, this map will be
832    // empty.
833    //
834    // For example, a key "sku1" with field mask
835    // "products.color_info" indicates there is a match between
836    // "sku1" [ColorInfo][google.cloud.retail.v2alpha.ColorInfo] and the query.
837    map<string, google.protobuf.FieldMask> matching_variant_fields = 4;
838
839    // The rollup matching
840    // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT]
841    // [Product][google.cloud.retail.v2alpha.Product] attributes. The key is one
842    // of the
843    // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2alpha.SearchRequest.variant_rollup_keys].
844    // The values are the merged and de-duplicated
845    // [Product][google.cloud.retail.v2alpha.Product] attributes. Notice that
846    // the rollup values are respect filter. For example, when filtering by
847    // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is
848    // returned.
849    //
850    // For textual and numerical attributes, the rollup values is a list of
851    // string or double values with type
852    // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if
853    // there are two variants with colors "red" and "blue", the rollup values
854    // are
855    //
856    //     { key: "colorFamilies"
857    //       value {
858    //         list_value {
859    //           values { string_value: "red" }
860    //           values { string_value: "blue" }
861    //          }
862    //       }
863    //     }
864    //
865    // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], the
866    // rollup values is a double value with type
867    // [google.protobuf.Value][google.protobuf.Value]. For example,
868    // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there
869    // are 10 variants in this product are available in the store "store1".
870    map<string, google.protobuf.Value> variant_rollup_values = 5;
871
872    // Specifies previous events related to this product for this user based on
873    // [UserEvent][google.cloud.retail.v2alpha.UserEvent] with same
874    // [SearchRequest.visitor_id][google.cloud.retail.v2alpha.SearchRequest.visitor_id]
875    // or [UserInfo.user_id][google.cloud.retail.v2alpha.UserInfo.user_id].
876    //
877    // This is set only when
878    // [SearchRequest.PersonalizationSpec.mode][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.mode]
879    // is
880    // [SearchRequest.PersonalizationSpec.Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO].
881    //
882    // Possible values:
883    //
884    // * `purchased`: Indicates that this product has been purchased before.
885    repeated string personal_labels = 7;
886  }
887
888  // A facet result.
889  message Facet {
890    // A facet value which contains value names and their count.
891    message FacetValue {
892      // A facet value which contains values.
893      oneof facet_value {
894        // Text value of a facet, such as "Black" for facet "colorFamilies".
895        string value = 1;
896
897        // Interval value for a facet, such as [10, 20) for facet "price".
898        Interval interval = 2;
899      }
900
901      // Number of items that have this facet value.
902      int64 count = 3;
903
904      // The minimum value in the
905      // [FacetValue.interval][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.interval].
906      // Only supported on numerical facets and returned if
907      // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.return_min_max]
908      // is true.
909      double min_value = 5;
910
911      // The maximum value in the
912      // [FacetValue.interval][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.interval].
913      // Only supported on numerical facets and returned if
914      // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.return_min_max]
915      // is true.
916      double max_value = 6;
917    }
918
919    // The key for this facet. E.g., "colorFamilies" or "price" or
920    // "attributes.attr1".
921    string key = 1;
922
923    // The facet values for this field.
924    repeated FacetValue values = 2;
925
926    // Whether the facet is dynamically generated.
927    bool dynamic_facet = 3;
928  }
929
930  // Information describing query expansion including whether expansion has
931  // occurred.
932  message QueryExpansionInfo {
933    // Bool describing whether query expansion has occurred.
934    bool expanded_query = 1;
935
936    // Number of pinned results. This field will only be set when expansion
937    // happens and
938    // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.pin_unexpanded_results]
939    // is set to true.
940    int64 pinned_result_count = 2;
941  }
942
943  // A list of matched items. The order represents the ranking.
944  repeated SearchResult results = 1;
945
946  // Results of facets requested by user.
947  repeated Facet facets = 2;
948
949  // The estimated total count of matched items irrespective of pagination. The
950  // count of [results][google.cloud.retail.v2alpha.SearchResponse.results]
951  // returned by pagination may be less than the
952  // [total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] that
953  // matches.
954  int32 total_size = 3;
955
956  // Contains the spell corrected query, if found. If the spell correction type
957  // is AUTOMATIC, then the search results are based on corrected_query.
958  // Otherwise the original query is used for search.
959  string corrected_query = 4;
960
961  // A unique search token. This should be included in the
962  // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this
963  // search, which enables accurate attribution of search model performance.
964  string attribution_token = 5;
965
966  // A token that can be sent as
967  // [SearchRequest.page_token][google.cloud.retail.v2alpha.SearchRequest.page_token]
968  // to retrieve the next page. If this field is omitted, there are no
969  // subsequent pages.
970  string next_page_token = 6;
971
972  // Query expansion information for the returned results.
973  QueryExpansionInfo query_expansion_info = 7;
974
975  // The URI of a customer-defined redirect page. If redirect action is
976  // triggered, no search is performed, and only
977  // [redirect_uri][google.cloud.retail.v2alpha.SearchResponse.redirect_uri] and
978  // [attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token]
979  // are set in the response.
980  string redirect_uri = 10;
981
982  // The fully qualified resource name of applied
983  // [controls](https://cloud.google.com/retail/docs/serving-control-rules).
984  repeated string applied_controls = 12;
985
986  // The invalid
987  // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs]
988  // that are not applied during serving.
989  repeated SearchRequest.BoostSpec.ConditionBoostSpec
990      invalid_condition_boost_specs = 14;
991
992  // Metadata related to A/B testing
993  // [Experiment][google.cloud.retail.v2alpha.Experiment] associated with this
994  // response. Only exists when an experiment is triggered.
995  repeated ExperimentInfo experiment_info = 17;
996}
997
998// Metadata for active A/B testing [Experiments][].
999message ExperimentInfo {
1000  // Metadata for active serving config A/B tests.
1001  message ServingConfigExperiment {
1002    // The fully qualified resource name of the original
1003    // [SearchRequest.placement][google.cloud.retail.v2alpha.SearchRequest.placement]
1004    // in the search request prior to reassignment by experiment API. For
1005    // example: `projects/*/locations/*/catalogs/*/servingConfigs/*`.
1006    string original_serving_config = 1 [(google.api.resource_reference) = {
1007      type: "retail.googleapis.com/ServingConfig"
1008    }];
1009
1010    // The fully qualified resource name of the serving config
1011    // [VariantArm.serving_config_id][] responsible for generating the search
1012    // response. For example:
1013    // `projects/*/locations/*/catalogs/*/servingConfigs/*`.
1014    string experiment_serving_config = 2 [(google.api.resource_reference) = {
1015      type: "retail.googleapis.com/ServingConfig"
1016    }];
1017  }
1018
1019  // Information associated with the specific experiment entity being recorded.
1020  oneof experiment_metadata {
1021    // A/B test between existing Cloud Retail Search
1022    // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s.
1023    ServingConfigExperiment serving_config_experiment = 2;
1024  }
1025
1026  // The fully qualified resource name of the experiment that provides the
1027  // serving config under test, should an active experiment exist. For example:
1028  // `projects/*/locations/global/catalogs/default_catalog/experiments/experiment_id`
1029  string experiment = 1 [(google.api.resource_reference) = {
1030    type: "retail.googleapis.com/Experiment"
1031  }];
1032}
1033