completion_service.proto 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. syntax = "proto3";
  15. package google.cloud.retail.v2;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/cloud/retail/v2/common.proto";
  21. import "google/cloud/retail/v2/import_config.proto";
  22. import "google/longrunning/operations.proto";
  23. option csharp_namespace = "Google.Cloud.Retail.V2";
  24. option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail";
  25. option java_multiple_files = true;
  26. option java_outer_classname = "CompletionServiceProto";
  27. option java_package = "com.google.cloud.retail.v2";
  28. option objc_class_prefix = "RETAIL";
  29. option php_namespace = "Google\\Cloud\\Retail\\V2";
  30. option ruby_package = "Google::Cloud::Retail::V2";
  31. // Auto-completion service for retail.
  32. //
  33. // This feature is only available for users who have Retail Search enabled.
  34. // Please enable Retail Search on Cloud Console before using this feature.
  35. service CompletionService {
  36. option (google.api.default_host) = "retail.googleapis.com";
  37. option (google.api.oauth_scopes) =
  38. "https://www.googleapis.com/auth/cloud-platform";
  39. // Completes the specified prefix with keyword suggestions.
  40. //
  41. // This feature is only available for users who have Retail Search enabled.
  42. // Please enable Retail Search on Cloud Console before using this feature.
  43. rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) {
  44. option (google.api.http) = {
  45. get: "/v2/{catalog=projects/*/locations/*/catalogs/*}:completeQuery"
  46. };
  47. }
  48. // Bulk import of processed completion dataset.
  49. //
  50. // Request processing is asynchronous. Partial updating is not supported.
  51. //
  52. // The operation is successfully finished only after the imported suggestions
  53. // are indexed successfully and ready for serving. The process takes hours.
  54. //
  55. // This feature is only available for users who have Retail Search enabled.
  56. // Please enable Retail Search on Cloud Console before using this feature.
  57. rpc ImportCompletionData(ImportCompletionDataRequest)
  58. returns (google.longrunning.Operation) {
  59. option (google.api.http) = {
  60. post: "/v2/{parent=projects/*/locations/*/catalogs/*}/completionData:import"
  61. body: "*"
  62. };
  63. option (google.longrunning.operation_info) = {
  64. response_type: "google.cloud.retail.v2.ImportCompletionDataResponse"
  65. metadata_type: "google.cloud.retail.v2.ImportMetadata"
  66. };
  67. }
  68. }
  69. // Auto-complete parameters.
  70. message CompleteQueryRequest {
  71. // Required. Catalog for which the completion is performed.
  72. //
  73. // Full resource name of catalog, such as
  74. // `projects/*/locations/global/catalogs/default_catalog`.
  75. string catalog = 1 [
  76. (google.api.field_behavior) = REQUIRED,
  77. (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" }
  78. ];
  79. // Required. The query used to generate suggestions.
  80. //
  81. // The maximum number of allowed characters is 255.
  82. string query = 2 [(google.api.field_behavior) = REQUIRED];
  83. // Required field. A unique identifier for tracking visitors. For example,
  84. // this could be implemented with an HTTP cookie, which should be able to
  85. // uniquely identify a visitor on a single device. This unique identifier
  86. // should not change if the visitor logs in or out of the website.
  87. //
  88. // The field must be a UTF-8 encoded string with a length limit of 128
  89. // characters. Otherwise, an INVALID_ARGUMENT error is returned.
  90. string visitor_id = 7;
  91. // Note that this field applies for `user-data` dataset only. For requests
  92. // with `cloud-retail` dataset, setting this field has no effect.
  93. //
  94. // The language filters applied to the output suggestions. If set, it should
  95. // contain the language of the query. If not set, suggestions are returned
  96. // without considering language restrictions. This is the BCP-47 language
  97. // code, such as "en-US" or "sr-Latn". For more information, see [Tags for
  98. // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum
  99. // number of language codes is 3.
  100. repeated string language_codes = 3;
  101. // The device type context for completion suggestions.
  102. // It is useful to apply different suggestions on different device types, e.g.
  103. // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device
  104. // types.
  105. //
  106. // Supported formats:
  107. //
  108. // * `UNKNOWN_DEVICE_TYPE`
  109. //
  110. // * `DESKTOP`
  111. //
  112. // * `MOBILE`
  113. //
  114. // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`.
  115. string device_type = 4;
  116. // Determines which dataset to use for fetching completion. "user-data" will
  117. // use the imported dataset through
  118. // [CompletionService.ImportCompletionData][google.cloud.retail.v2.CompletionService.ImportCompletionData].
  119. // "cloud-retail" will use the dataset generated by cloud retail based on user
  120. // events. If leave empty, it will use the "user-data".
  121. //
  122. // Current supported values:
  123. //
  124. // * user-data
  125. //
  126. // * cloud-retail:
  127. // This option requires enabling auto-learning function first. See
  128. // [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset).
  129. string dataset = 6;
  130. // Completion max suggestions. If left unset or set to 0, then will fallback
  131. // to the configured value
  132. // [CompletionConfig.max_suggestions][google.cloud.retail.v2.CompletionConfig.max_suggestions].
  133. //
  134. // The maximum allowed max suggestions is 20. If it is set higher, it will be
  135. // capped by 20.
  136. int32 max_suggestions = 5;
  137. }
  138. // Response of the auto-complete query.
  139. message CompleteQueryResponse {
  140. // Resource that represents completion results.
  141. message CompletionResult {
  142. // The suggestion for the query.
  143. string suggestion = 1;
  144. // Custom attributes for the suggestion term.
  145. //
  146. // * For "user-data", the attributes are additional custom attributes
  147. // ingested through BigQuery.
  148. //
  149. // * For "cloud-retail", the attributes are product attributes generated
  150. // by Cloud Retail. It requires
  151. // [UserEvent.product_details][google.cloud.retail.v2.UserEvent.product_details]
  152. // is imported properly.
  153. map<string, CustomAttribute> attributes = 2;
  154. }
  155. // Recent search of this user.
  156. message RecentSearchResult {
  157. // The recent search query.
  158. string recent_search = 1;
  159. }
  160. // Results of the matching suggestions. The result list is ordered and the
  161. // first result is top suggestion.
  162. repeated CompletionResult completion_results = 1;
  163. // A unique complete token. This should be included in the
  164. // [UserEvent.completion_detail][google.cloud.retail.v2.UserEvent.completion_detail]
  165. // for search events resulting from this completion, which enables accurate
  166. // attribution of complete model performance.
  167. string attribution_token = 2;
  168. // Matched recent searches of this user. The maximum number of recent searches
  169. // is 10. This field is a restricted feature. Contact Retail Search support
  170. // team if you are interested in enabling it.
  171. //
  172. // This feature is only available when
  173. // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2.CompleteQueryRequest.visitor_id]
  174. // field is set and [UserEvent][google.cloud.retail.v2.UserEvent] is imported.
  175. // The recent searches satisfy the follow rules:
  176. //
  177. // * They are ordered from latest to oldest.
  178. //
  179. // * They are matched with
  180. // [CompleteQueryRequest.query][google.cloud.retail.v2.CompleteQueryRequest.query]
  181. // case insensitively.
  182. //
  183. // * They are transformed to lower case.
  184. //
  185. // * They are UTF-8 safe.
  186. //
  187. // Recent searches are deduplicated. More recent searches will be reserved
  188. // when duplication happens.
  189. repeated RecentSearchResult recent_search_results = 3;
  190. }