auto_suggestion_service.proto 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. // Copyright 2020 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.dataqna.v1alpha;
  16. import "google/api/annotations.proto";
  17. import "google/api/field_behavior.proto";
  18. import "google/api/resource.proto";
  19. import "google/cloud/dataqna/v1alpha/annotated_string.proto";
  20. import "google/api/client.proto";
  21. option csharp_namespace = "Google.Cloud.DataQnA.V1Alpha";
  22. option go_package = "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha;dataqna";
  23. option java_multiple_files = true;
  24. option java_outer_classname = "AutoSuggestionServiceProto";
  25. option java_package = "com.google.cloud.dataqna.v1alpha";
  26. option php_namespace = "Google\\Cloud\\DataQnA\\V1alpha";
  27. option ruby_package = "Google::Cloud::DataQnA::V1alpha";
  28. // This stateless API provides automatic suggestions for natural language
  29. // queries for the data sources in the provided project and location.
  30. //
  31. // The service provides a resourceless operation `suggestQueries` that can be
  32. // called to get a list of suggestions for a given incomplete query and scope
  33. // (or list of scopes) under which the query is to be interpreted.
  34. //
  35. // There are two types of suggestions, ENTITY for single entity suggestions
  36. // and TEMPLATE for full sentences. By default, both types are returned.
  37. //
  38. // Example Request:
  39. // ```
  40. // GetSuggestions({
  41. // parent: "locations/us/projects/my-project"
  42. // scopes:
  43. // "//bigquery.googleapis.com/projects/my-project/datasets/my-dataset/tables/my-table"
  44. // query: "top it"
  45. // })
  46. // ```
  47. //
  48. // The service will retrieve information based on the given scope(s) and give
  49. // suggestions based on that (e.g. "top item" for "top it" if "item" is a known
  50. // dimension for the provided scope).
  51. // ```
  52. // suggestions {
  53. // suggestion_info {
  54. // annotated_suggestion {
  55. // text_formatted: "top item by sum of usd_revenue_net"
  56. // markups {
  57. // type: DIMENSION
  58. // start_char_index: 4
  59. // length: 4
  60. // }
  61. // markups {
  62. // type: METRIC
  63. // start_char_index: 19
  64. // length: 15
  65. // }
  66. // }
  67. // query_matches {
  68. // start_char_index: 0
  69. // length: 6
  70. // }
  71. // }
  72. // suggestion_type: TEMPLATE
  73. // ranking_score: 0.9
  74. // }
  75. // suggestions {
  76. // suggestion_info {
  77. // annotated_suggestion {
  78. // text_formatted: "item"
  79. // markups {
  80. // type: DIMENSION
  81. // start_char_index: 4
  82. // length: 2
  83. // }
  84. // }
  85. // query_matches {
  86. // start_char_index: 0
  87. // length: 6
  88. // }
  89. // }
  90. // suggestion_type: ENTITY
  91. // ranking_score: 0.8
  92. // }
  93. // ```
  94. service AutoSuggestionService {
  95. option (google.api.default_host) = "dataqna.googleapis.com";
  96. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  97. // Gets a list of suggestions based on a prefix string.
  98. // AutoSuggestion tolerance should be less than 1 second.
  99. rpc SuggestQueries(SuggestQueriesRequest) returns (SuggestQueriesResponse) {
  100. option (google.api.http) = {
  101. post: "/v1alpha/{parent=projects/*/locations/*}:suggestQueries"
  102. body: "*"
  103. };
  104. }
  105. }
  106. // Request for query suggestions.
  107. message SuggestQueriesRequest {
  108. // Required. The parent of the suggestion query is the resource denoting the project and
  109. // location.
  110. string parent = 1 [
  111. (google.api.field_behavior) = REQUIRED,
  112. (google.api.resource_reference) = {
  113. type: "locations.googleapis.com/Location"
  114. }
  115. ];
  116. // The scopes to which this search is restricted. The only supported scope
  117. // pattern is
  118. // `//bigquery.googleapis.com/projects/{GCP-PROJECT-ID}/datasets/{DATASET-ID}/tables/{TABLE-ID}`.
  119. repeated string scopes = 2;
  120. // User query for which to generate suggestions. If the query is empty, zero
  121. // state suggestions are returned. This allows UIs to display suggestions
  122. // right away, helping the user to get a sense of what a query might look
  123. // like.
  124. string query = 3;
  125. // The requested suggestion type. Multiple suggestion types can be
  126. // requested, but there is no guarantee that the service will return
  127. // suggestions for each type. Suggestions for a requested type might rank
  128. // lower than suggestions for other types and the service may decide to cut
  129. // these suggestions off.
  130. repeated SuggestionType suggestion_types = 4;
  131. }
  132. // A suggestion for a query with a ranking score.
  133. message Suggestion {
  134. // Detailed information about the suggestion.
  135. SuggestionInfo suggestion_info = 1;
  136. // The score of the suggestion. This can be used to define ordering in UI.
  137. // The score represents confidence in the suggestion where higher is better.
  138. // All score values must be in the range [0, 1).
  139. double ranking_score = 2;
  140. // The type of the suggestion.
  141. SuggestionType suggestion_type = 3;
  142. }
  143. // Detailed information about the suggestion.
  144. message SuggestionInfo {
  145. // MatchInfo describes which part of suggestion matched with data in user
  146. // typed query. This can be used to highlight matching parts in the UI. This
  147. // is different from the annotations provided in annotated_suggestion. The
  148. // annotated_suggestion provides information about the semantic meaning, while
  149. // this provides information about how it relates to the input.
  150. //
  151. // Example:
  152. // user query: `top products`
  153. //
  154. // ```
  155. // annotated_suggestion {
  156. // text_formatted = "top product_group"
  157. // html_formatted = "top <b>product_group</b>"
  158. // markups {
  159. // {type: TEXT, start_char_index: 0, length: 3}
  160. // {type: DIMENSION, start_char_index: 4, length: 13}
  161. // }
  162. // }
  163. //
  164. // query_matches {
  165. // { start_char_index: 0, length: 3 }
  166. // { start_char_index: 4, length: 7}
  167. // }
  168. // ```
  169. message MatchInfo {
  170. // Unicode character index of the string annotation.
  171. int32 start_char_index = 1;
  172. // Count of unicode characters of this substring.
  173. int32 length = 2;
  174. }
  175. // Annotations for the suggestion. This provides information about which part
  176. // of the suggestion corresponds to what semantic meaning (e.g. a metric).
  177. AnnotatedString annotated_suggestion = 1;
  178. // Matches between user query and the annotated string.
  179. repeated MatchInfo query_matches = 2;
  180. }
  181. // Response to SuggestQueries.
  182. message SuggestQueriesResponse {
  183. // A list of suggestions.
  184. repeated Suggestion suggestions = 1;
  185. }
  186. // The type of suggestion.
  187. enum SuggestionType {
  188. // No suggestiont type is specified.
  189. SUGGESTION_TYPE_UNSPECIFIED = 0;
  190. // Entity suggestion type. Suggestions are for single entities.
  191. ENTITY = 1;
  192. // Template suggestion type. Suggestions are for full sentences.
  193. TEMPLATE = 2;
  194. }