completion_service.proto 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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.v2beta;
  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/v2beta/common.proto";
  21. import "google/cloud/retail/v2beta/import_config.proto";
  22. import "google/longrunning/operations.proto";
  23. option csharp_namespace = "Google.Cloud.Retail.V2Beta";
  24. option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail";
  25. option java_multiple_files = true;
  26. option java_outer_classname = "CompletionServiceProto";
  27. option java_package = "com.google.cloud.retail.v2beta";
  28. option objc_class_prefix = "RETAIL";
  29. option php_namespace = "Google\\Cloud\\Retail\\V2beta";
  30. option ruby_package = "Google::Cloud::Retail::V2beta";
  31. // Auto-completion service for retail.
  32. //
  33. // This feature is only available for users who have Retail Search enabled.
  34. // Contact Retail Support (retail-search-support@google.com) if you are
  35. // interested in using Retail Search.
  36. service CompletionService {
  37. option (google.api.default_host) = "retail.googleapis.com";
  38. option (google.api.oauth_scopes) =
  39. "https://www.googleapis.com/auth/cloud-platform";
  40. // Completes the specified prefix with keyword suggestions.
  41. //
  42. // This feature is only available for users who have Retail Search enabled.
  43. // Contact Retail Support (retail-search-support@google.com) if you are
  44. // interested in using Retail Search.
  45. rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) {
  46. option (google.api.http) = {
  47. get: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:completeQuery"
  48. };
  49. }
  50. // Bulk import of processed completion dataset.
  51. //
  52. // Request processing may be synchronous. Partial updating is not supported.
  53. //
  54. // This feature is only available for users who have Retail Search enabled.
  55. // Contact Retail Support (retail-search-support@google.com) if you are
  56. // interested in using Retail Search.
  57. rpc ImportCompletionData(ImportCompletionDataRequest)
  58. returns (google.longrunning.Operation) {
  59. option (google.api.http) = {
  60. post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/completionData:import"
  61. body: "*"
  62. };
  63. option (google.longrunning.operation_info) = {
  64. response_type: "google.cloud.retail.v2beta.ImportCompletionDataResponse"
  65. metadata_type: "google.cloud.retail.v2beta.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. // A unique identifier for tracking visitors. For example, this could be
  84. // implemented with an HTTP cookie, which should be able to uniquely identify
  85. // a visitor on a single device. This unique identifier should not change if
  86. // 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. // The list of languages of the query. This is
  92. // the BCP-47 language code, such as "en-US" or "sr-Latn".
  93. // For more information, see
  94. // [Tags for Identifying Languages](https://tools.ietf.org/html/bcp47).
  95. //
  96. // The maximum number of allowed characters is 255.
  97. // Only "en-US" is currently supported.
  98. repeated string language_codes = 3;
  99. // The device type context for completion suggestions.
  100. // It is useful to apply different suggestions on different device types, e.g.
  101. // DESKTOP, MOBILE. If it is empty, the suggestions are across all device
  102. // types.
  103. //
  104. // Supported formats:
  105. //
  106. // * UNKNOWN_DEVICE_TYPE
  107. //
  108. // * DESKTOP
  109. //
  110. // * MOBILE
  111. //
  112. // * A customized string starts with OTHER_, e.g. OTHER_IPHONE.
  113. string device_type = 4;
  114. // Determines which dataset to use for fetching completion. "user-data" will
  115. // use the imported dataset through
  116. // [CompletionService.ImportCompletionData][google.cloud.retail.v2beta.CompletionService.ImportCompletionData].
  117. // "cloud-retail" will use the dataset generated by cloud retail based on user
  118. // events. If leave empty, it will use the "user-data".
  119. //
  120. // Current supported values:
  121. //
  122. // * user-data
  123. //
  124. // * cloud-retail
  125. // This option is not automatically enabled. Before using cloud-retail,
  126. // contact retail-search-support@google.com first.
  127. string dataset = 6;
  128. // Completion max suggestions.
  129. //
  130. // The maximum allowed max suggestions is 20. The default value is 20.
  131. int32 max_suggestions = 5;
  132. }
  133. // Response of the auto-complete query.
  134. message CompleteQueryResponse {
  135. // Resource that represents completion results.
  136. message CompletionResult {
  137. // The suggestion for the query.
  138. string suggestion = 1;
  139. // Additional custom attributes ingested through BigQuery.
  140. map<string, CustomAttribute> attributes = 2;
  141. }
  142. // Recent search of this user.
  143. message RecentSearchResult {
  144. // The recent search query.
  145. string recent_search = 1;
  146. }
  147. // Results of the matching suggestions. The result list is ordered and the
  148. // first result is top suggestion.
  149. repeated CompletionResult completion_results = 1;
  150. // A unique complete token. This should be included in the
  151. // [SearchRequest][google.cloud.retail.v2beta.SearchRequest] resulting from
  152. // this completion, which enables accurate attribution of complete model
  153. // performance.
  154. string attribution_token = 2;
  155. // Matched recent searches of this user. This field is a restricted feature.
  156. // Contact Retail Support (retail-search-support@google.com) if you are
  157. // interested in enabling it.
  158. //
  159. // This feature is only available when
  160. // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2beta.CompleteQueryRequest.visitor_id]
  161. // field is set and [UserEvent][google.cloud.retail.v2beta.UserEvent] is
  162. // imported. The recent searches satisfy the follow rules:
  163. // * They are ordered from latest to oldest.
  164. // * They are matched with
  165. // [CompleteQueryRequest.query][google.cloud.retail.v2beta.CompleteQueryRequest.query]
  166. // case insensitively.
  167. // * They are transformed to lower cases.
  168. // * They are UTF-8 safe.
  169. //
  170. // Recent searches are deduplicated. More recent searches will be reserved
  171. // when duplication happens.
  172. repeated RecentSearchResult recent_search_results = 3;
  173. }