search_service.proto 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  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.v2alpha;
  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/v2alpha/common.proto";
  21. import "google/cloud/retail/v2alpha/product.proto";
  22. import "google/protobuf/field_mask.proto";
  23. import "google/protobuf/struct.proto";
  24. import "google/protobuf/timestamp.proto";
  25. import "google/protobuf/wrappers.proto";
  26. option csharp_namespace = "Google.Cloud.Retail.V2Alpha";
  27. option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail";
  28. option java_multiple_files = true;
  29. option java_outer_classname = "SearchServiceProto";
  30. option java_package = "com.google.cloud.retail.v2alpha";
  31. option objc_class_prefix = "RETAIL";
  32. option php_namespace = "Google\\Cloud\\Retail\\V2alpha";
  33. option ruby_package = "Google::Cloud::Retail::V2alpha";
  34. // Service for search.
  35. //
  36. // This feature is only available for users who have Retail Search enabled.
  37. // Contact Retail Support (retail-search-support@google.com) if you are
  38. // interested in using Retail Search.
  39. service SearchService {
  40. option (google.api.default_host) = "retail.googleapis.com";
  41. option (google.api.oauth_scopes) =
  42. "https://www.googleapis.com/auth/cloud-platform";
  43. // Performs a search.
  44. //
  45. // This feature is only available for users who have Retail Search enabled.
  46. // Contact Retail Support (retail-search-support@google.com) if you are
  47. // interested in using Retail Search.
  48. rpc Search(SearchRequest) returns (SearchResponse) {
  49. option (google.api.http) = {
  50. post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:search"
  51. body: "*"
  52. };
  53. }
  54. }
  55. // Request message for
  56. // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]
  57. // method.
  58. message SearchRequest {
  59. // A facet specification to perform faceted search.
  60. message FacetSpec {
  61. // Specifies how a facet is computed.
  62. message FacetKey {
  63. // Required. Supported textual and numerical facet keys in
  64. // [Product][google.cloud.retail.v2alpha.Product] object, over which the
  65. // facet values are computed. Facet key is case-sensitive.
  66. //
  67. // Allowed facet keys when
  68. // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query]
  69. // is not specified:
  70. //
  71. // Textual facet keys:
  72. // * brands
  73. // * categories
  74. // * genders
  75. // * ageGroups
  76. // * availability
  77. // * colorFamilies
  78. // * colors
  79. // * sizes
  80. // * materials
  81. // * patterns
  82. // * conditions
  83. // * attributes.key
  84. // * pickupInStore
  85. // * shipToStore
  86. // * sameDayDelivery
  87. // * nextDayDelivery
  88. // * customFulfillment1
  89. // * customFulfillment2
  90. // * customFulfillment3
  91. // * customFulfillment4
  92. // * customFulfillment5
  93. //
  94. // Numeric facet keys:
  95. // * price
  96. // * discount
  97. // * rating
  98. // * ratingCount
  99. // * attributes.key
  100. string key = 1 [(google.api.field_behavior) = REQUIRED];
  101. // Set only if values should be bucketized into intervals. Must be set
  102. // for facets with numerical values. Must not be set for facet with text
  103. // values. Maximum number of intervals is 30.
  104. repeated Interval intervals = 2;
  105. // Only get facet for the given restricted values. For example, when using
  106. // "pickupInStore" as key and set restricted values to
  107. // ["store123", "store456"], only facets for "store123" and "store456" are
  108. // returned. Only supported on textual fields and fulfillments.
  109. // Maximum is 20.
  110. //
  111. // Must be set for the fulfillment facet keys:
  112. //
  113. // * pickupInStore
  114. //
  115. // * shipToStore
  116. //
  117. // * sameDayDelivery
  118. //
  119. // * nextDayDelivery
  120. //
  121. // * customFulfillment1
  122. //
  123. // * customFulfillment2
  124. //
  125. // * customFulfillment3
  126. //
  127. // * customFulfillment4
  128. //
  129. // * customFulfillment5
  130. repeated string restricted_values = 3;
  131. // Only get facet values that start with the given string prefix. For
  132. // example, suppose "categories" has three values "Women > Shoe",
  133. // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the
  134. // "categories" facet will give only "Women > Shoe" and "Women > Dress".
  135. // Only supported on textual fields. Maximum is 10.
  136. repeated string prefixes = 8;
  137. // Only get facet values that contains the given strings. For example,
  138. // suppose "categories" has three values "Women > Shoe",
  139. // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the
  140. // "categories" facet will give only "Women > Shoe" and "Men > Shoe".
  141. // Only supported on textual fields. Maximum is 10.
  142. repeated string contains = 9;
  143. // The order in which [Facet.values][] are returned.
  144. //
  145. // Allowed values are:
  146. //
  147. // * "count desc", which means order by [Facet.FacetValue.count][]
  148. // descending.
  149. //
  150. // * "value desc", which means order by [Facet.FacetValue.value][]
  151. // descending.
  152. // Only applies to textual facets.
  153. //
  154. // If not set, textual values are sorted in [natural
  155. // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical
  156. // intervals are sorted in the order given by
  157. // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.intervals];
  158. // [FulfillmentInfo.ids][] are sorted in the order given by
  159. // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.restricted_values].
  160. string order_by = 4;
  161. // The query that is used to compute facet for the given facet key.
  162. // When provided, it will override the default behavior of facet
  163. // computation. The query syntax is the same as a filter expression. See
  164. // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter]
  165. // for detail syntax and limitations. Notice that there is no limitation
  166. // on
  167. // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key]
  168. // when query is specified.
  169. //
  170. // In the response, [FacetValue.value][] will be always "1" and
  171. // [FacetValue.count][] will be the number of results that matches the
  172. // query.
  173. //
  174. // For example, you can set a customized facet for "shipToStore",
  175. // where
  176. // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key]
  177. // is "customizedShipToStore", and
  178. // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query]
  179. // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")".
  180. // Then the facet will count the products that are both in stock and ship
  181. // to store "123".
  182. string query = 5;
  183. }
  184. // Required. The facet key specification.
  185. FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED];
  186. // Maximum of facet values that should be returned for this facet. If
  187. // unspecified, defaults to 20. The maximum allowed value is 300. Values
  188. // above 300 will be coerced to 300.
  189. //
  190. // If this field is negative, an INVALID_ARGUMENT is returned.
  191. int32 limit = 2;
  192. // List of keys to exclude when faceting.
  193. //
  194. // By default,
  195. // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key]
  196. // is not excluded from the filter unless it is listed in this field.
  197. //
  198. // For example, suppose there are 100 products with color facet "Red" and
  199. // 200 products with color facet "Blue". A query containing the filter
  200. // "colorFamilies:ANY("Red")" and have "colorFamilies" as
  201. // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key]
  202. // will by default return the "Red" with count 100.
  203. //
  204. // If this field contains "colorFamilies", then the query returns both the
  205. // "Red" with count 100 and "Blue" with count 200, because the
  206. // "colorFamilies" key is now excluded from the filter.
  207. //
  208. // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error
  209. // is returned.
  210. repeated string excluded_filter_keys = 3;
  211. // Enables dynamic position for this facet. If set to true, the position of
  212. // this facet among all facets in the response is determined by Google
  213. // Retail Search. It will be ordered together with dynamic facets if dynamic
  214. // facets is enabled. If set to false, the position of this facet in the
  215. // response will be the same as in the request, and it will be ranked before
  216. // the facets with dynamic position enable and all dynamic facets.
  217. //
  218. // For example, you may always want to have rating facet returned in
  219. // the response, but it's not necessarily to always display the rating facet
  220. // at the top. In that case, you can set enable_dynamic_position to true so
  221. // that the position of rating facet in response will be determined by
  222. // Google Retail Search.
  223. //
  224. // Another example, assuming you have the following facets in the request:
  225. //
  226. // * "rating", enable_dynamic_position = true
  227. //
  228. // * "price", enable_dynamic_position = false
  229. //
  230. // * "brands", enable_dynamic_position = false
  231. //
  232. // And also you have a dynamic facets enable, which will generate a facet
  233. // 'gender'. Then the final order of the facets in the response can be
  234. // ("price", "brands", "rating", "gender") or ("price", "brands", "gender",
  235. // "rating") depends on how Google Retail Search orders "gender" and
  236. // "rating" facets. However, notice that "price" and "brands" will always be
  237. // ranked at 1st and 2nd position since their enable_dynamic_position are
  238. // false.
  239. bool enable_dynamic_position = 4;
  240. }
  241. // The specifications of dynamically generated facets.
  242. message DynamicFacetSpec {
  243. // Enum to control DynamicFacet mode
  244. enum Mode {
  245. // Default value.
  246. MODE_UNSPECIFIED = 0;
  247. // Disable Dynamic Facet.
  248. DISABLED = 1;
  249. // Automatic mode built by Google Retail Search.
  250. ENABLED = 2;
  251. }
  252. // Mode of the DynamicFacet feature.
  253. // Defaults to
  254. // [Mode.DISABLED][google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode.DISABLED]
  255. // if it's unset.
  256. Mode mode = 1;
  257. }
  258. // Boost specification to boost certain items.
  259. message BoostSpec {
  260. // Boost applies to products which match a condition.
  261. message ConditionBoostSpec {
  262. // An expression which specifies a boost condition. The syntax and
  263. // supported fields are the same as a filter expression. See
  264. // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter]
  265. // for detail syntax and limitations.
  266. //
  267. // Examples:
  268. //
  269. // * To boost products with product ID "product_1" or "product_2", and
  270. // color "Red" or "Blue":
  271. // ```
  272. // (id: ANY("product_1", "product_2"))
  273. // AND
  274. // (colorFamilies: ANY("Red", "Blue"))
  275. // ```
  276. string condition = 1;
  277. // Strength of the condition boost, which should be in [-1, 1]. Negative
  278. // boost means demotion. Default is 0.0.
  279. //
  280. // Setting to 1.0 gives the item a big promotion. However, it does not
  281. // necessarily mean that the boosted item will be the top result at all
  282. // times, nor that other items will be excluded. Results could still be
  283. // shown even when none of them matches the condition. And results that
  284. // are significantly more relevant to the search query can still trump
  285. // your heavily favored but irrelevant items.
  286. //
  287. // Setting to -1.0 gives the item a big demotion. However, results that
  288. // are deeply relevant might still be shown. The item will have an
  289. // upstream battle to get a fairly high ranking, but it is not blocked out
  290. // completely.
  291. //
  292. // Setting to 0.0 means no boost applied. The boosting condition is
  293. // ignored.
  294. float boost = 2;
  295. }
  296. // Condition boost specifications. If a product matches multiple conditions
  297. // in the specifictions, boost scores from these specifications are all
  298. // applied and combined in a non-linear way. Maximum number of
  299. // specifications is 10.
  300. repeated ConditionBoostSpec condition_boost_specs = 1;
  301. }
  302. // Specification to determine under which conditions query expansion should
  303. // occur.
  304. message QueryExpansionSpec {
  305. // Enum describing under which condition query expansion should occur.
  306. enum Condition {
  307. // Unspecified query expansion condition. This defaults to
  308. // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED].
  309. CONDITION_UNSPECIFIED = 0;
  310. // Disabled query expansion. Only the exact search query is used, even if
  311. // [SearchResponse.total_size][google.cloud.retail.v2alpha.SearchResponse.total_size]
  312. // is zero.
  313. DISABLED = 1;
  314. // Automatic query expansion built by Google Retail Search.
  315. AUTO = 3;
  316. }
  317. // The condition under which query expansion should occur. Default to
  318. // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED].
  319. Condition condition = 1;
  320. }
  321. // The relevance threshold of the search results. The higher relevance
  322. // threshold is, the higher relevant results are shown and the less number of
  323. // results are returned.
  324. enum RelevanceThreshold {
  325. // Default value. Defaults to
  326. // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH].
  327. RELEVANCE_THRESHOLD_UNSPECIFIED = 0;
  328. // High relevance threshold.
  329. HIGH = 1;
  330. // Medium relevance threshold.
  331. MEDIUM = 2;
  332. // Low relevance threshold.
  333. LOW = 3;
  334. // Lowest relevance threshold.
  335. LOWEST = 4;
  336. }
  337. // Required. The resource name of the search engine placement, such as
  338. // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`.
  339. // This field is used to identify the set of models that will be used to make
  340. // the search.
  341. //
  342. // We currently support one placement with the following ID:
  343. //
  344. // * `default_search`.
  345. string placement = 1 [(google.api.field_behavior) = REQUIRED];
  346. // The branch resource name, such as
  347. // `projects/*/locations/global/catalogs/default_catalog/branches/0`.
  348. //
  349. // Use "default_branch" as the branch ID or leave this field empty, to search
  350. // products under the default branch.
  351. string branch = 2 [
  352. (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" }
  353. ];
  354. // Raw search query.
  355. string query = 3;
  356. // Required. A unique identifier for tracking visitors. For example, this
  357. // could be implemented with an HTTP cookie, which should be able to uniquely
  358. // identify a visitor on a single device. This unique identifier should not
  359. // change if the visitor logs in or out of the website.
  360. //
  361. // The field must be a UTF-8 encoded string with a length limit of 128
  362. // characters. Otherwise, an INVALID_ARGUMENT error is returned.
  363. string visitor_id = 4 [(google.api.field_behavior) = REQUIRED];
  364. // User information.
  365. UserInfo user_info = 5;
  366. // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to
  367. // return. If unspecified, defaults to a reasonable value. The maximum allowed
  368. // value is 120. Values above 120 will be coerced to 120.
  369. //
  370. // If this field is negative, an INVALID_ARGUMENT is returned.
  371. int32 page_size = 7;
  372. // A page token
  373. // [SearchResponse.next_page_token][google.cloud.retail.v2alpha.SearchResponse.next_page_token],
  374. // received from a previous
  375. // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]
  376. // call. Provide this to retrieve the subsequent page.
  377. //
  378. // When paginating, all other parameters provided to
  379. // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]
  380. // must match the call that provided the page token. Otherwise, an
  381. // INVALID_ARGUMENT error is returned.
  382. string page_token = 8;
  383. // A 0-indexed integer that specifies the current offset (that is, starting
  384. // result location, amongst the
  385. // [Product][google.cloud.retail.v2alpha.Product]s deemed by the API as
  386. // relevant) in search results. This field is only considered if
  387. // [page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] is
  388. // unset.
  389. //
  390. // If this field is negative, an INVALID_ARGUMENT is returned.
  391. int32 offset = 9;
  392. // The filter syntax consists of an expression language for constructing a
  393. // predicate from one or more fields of the products being filtered. Filter
  394. // expression is case-sensitive.
  395. //
  396. // If this field is unrecognizable, an INVALID_ARGUMENT is returned.
  397. string filter = 10;
  398. // The filter applied to every search request when quality improvement such as
  399. // query expansion is needed. For example, if a query does not have enough
  400. // results, an expanded query with
  401. // [SearchRequest.canonical_filter][google.cloud.retail.v2alpha.SearchRequest.canonical_filter]
  402. // will be returned as a supplement of the original query. This field is
  403. // strongly recommended to achieve high search quality.
  404. //
  405. // See
  406. // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter]
  407. // for more details about filter syntax.
  408. string canonical_filter = 28;
  409. // The order in which products are returned. Products can be ordered by
  410. // a field in an [Product][google.cloud.retail.v2alpha.Product] object. Leave
  411. // it unset if ordered by relevance. OrderBy expression is case-sensitive.
  412. //
  413. // If this field is unrecognizable, an INVALID_ARGUMENT is returned.
  414. string order_by = 11;
  415. // Facet specifications for faceted search. If empty, no facets are returned.
  416. //
  417. // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error
  418. // is returned.
  419. repeated FacetSpec facet_specs = 12;
  420. // The specification for dynamically generated facets. Notice that only
  421. // textual facets can be dynamically generated.
  422. //
  423. // This feature requires additional allowlisting. Contact Retail Support
  424. // (retail-search-support@google.com) if you are interested in using dynamic
  425. // facet feature.
  426. DynamicFacetSpec dynamic_facet_spec = 21;
  427. // Boost specification to boost certain products.
  428. BoostSpec boost_spec = 13;
  429. // The query expansion specification that specifies the conditions under which
  430. // query expansion will occur.
  431. QueryExpansionSpec query_expansion_spec = 14;
  432. // The relevance threshold of the search results.
  433. //
  434. // Defaults to
  435. // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH],
  436. // which means only the most relevant results are shown, and the least number
  437. // of results are returned.
  438. RelevanceThreshold relevance_threshold = 15;
  439. // The keys to fetch and rollup the matching
  440. // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT]
  441. // [Product][google.cloud.retail.v2alpha.Product]s attributes. The attributes
  442. // from all the matching
  443. // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT]
  444. // [Product][google.cloud.retail.v2alpha.Product]s are merged and
  445. // de-duplicated. Notice that rollup
  446. // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT]
  447. // [Product][google.cloud.retail.v2alpha.Product]s attributes will lead to
  448. // extra query latency. Maximum number of keys is 10.
  449. //
  450. // For
  451. // [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info],
  452. // a fulfillment type and a fulfillment ID must be provided in the format of
  453. // "fulfillmentType.filfillmentId". E.g., in "pickupInStore.store123",
  454. // "pickupInStore" is fulfillment type and "store123" is the store ID.
  455. //
  456. // Supported keys are:
  457. //
  458. // * colorFamilies
  459. // * price
  460. // * originalPrice
  461. // * discount
  462. // * attributes.key, where key is any key in the
  463. // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes] map.
  464. // * pickupInStore.id, where id is any [FulfillmentInfo.ids][] for type
  465. // [FulfillmentInfo.Type.PICKUP_IN_STORE][].
  466. // * shipToStore.id, where id is any [FulfillmentInfo.ids][] for type
  467. // [FulfillmentInfo.Type.SHIP_TO_STORE][].
  468. // * sameDayDelivery.id, where id is any [FulfillmentInfo.ids][] for type
  469. // [FulfillmentInfo.Type.SAME_DAY_DELIVERY][].
  470. // * nextDayDelivery.id, where id is any [FulfillmentInfo.ids][] for type
  471. // [FulfillmentInfo.Type.NEXT_DAY_DELIVERY][].
  472. // * customFulfillment1.id, where id is any [FulfillmentInfo.ids][] for type
  473. // [FulfillmentInfo.Type.CUSTOM_TYPE_1][].
  474. // * customFulfillment2.id, where id is any [FulfillmentInfo.ids][] for type
  475. // [FulfillmentInfo.Type.CUSTOM_TYPE_2][].
  476. // * customFulfillment3.id, where id is any [FulfillmentInfo.ids][] for type
  477. // [FulfillmentInfo.Type.CUSTOM_TYPE_3][].
  478. // * customFulfillment4.id, where id is any [FulfillmentInfo.ids][] for type
  479. // [FulfillmentInfo.Type.CUSTOM_TYPE_4][].
  480. // * customFulfillment5.id, where id is any [FulfillmentInfo.ids][] for type
  481. // [FulfillmentInfo.Type.CUSTOM_TYPE_5][].
  482. //
  483. // If this field is set to an invalid value other than these, an
  484. // INVALID_ARGUMENT error is returned.
  485. repeated string variant_rollup_keys = 17;
  486. // The categories associated with a category page. Required for category
  487. // navigation queries to achieve good search quality. The format should be
  488. // the same as
  489. // [UserEvent.page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories];
  490. //
  491. // To represent full path of category, use '>' sign to separate different
  492. // hierarchies. If '>' is part of the category name, please replace it with
  493. // other character(s).
  494. //
  495. // Category pages include special pages such as sales or promotions. For
  496. // instance, a special sale page may have the category hierarchy:
  497. // "pageCategories" : ["Sales > 2017 Black Friday Deals"].
  498. repeated string page_categories = 23;
  499. }
  500. // Response message for
  501. // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]
  502. // method.
  503. message SearchResponse {
  504. // Represents the search results.
  505. message SearchResult {
  506. // [Product.id][google.cloud.retail.v2alpha.Product.id] of the searched
  507. // [Product][google.cloud.retail.v2alpha.Product].
  508. string id = 1;
  509. // The product data snippet in the search response. Only
  510. // [Product.name][google.cloud.retail.v2alpha.Product.name] is guaranteed to
  511. // be populated.
  512. //
  513. // [Product.variants][google.cloud.retail.v2alpha.Product.variants] contains
  514. // the product variants that match the search query. If there are multiple
  515. // product variants matching the query, top 5 most relevant product variants
  516. // are returned and ordered by relevancy.
  517. //
  518. // If relevancy can be deternmined, use
  519. // [matching_variant_fields][google.cloud.retail.v2alpha.SearchResponse.SearchResult.matching_variant_fields]
  520. // to look up matched product variants fields. If relevancy cannot be
  521. // determined, e.g. when searching "shoe" all products in a shoe product can
  522. // be a match, 5 product variants are returned but order is meaningless.
  523. Product product = 2;
  524. // The count of matched
  525. // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT]
  526. // [Product][google.cloud.retail.v2alpha.Product]s.
  527. int32 matching_variant_count = 3;
  528. // If a [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT]
  529. // [Product][google.cloud.retail.v2alpha.Product] matches the search query,
  530. // this map indicates which [Product][google.cloud.retail.v2alpha.Product]
  531. // fields are matched. The key is the
  532. // [Product.name][google.cloud.retail.v2alpha.Product.name], the value is a
  533. // field mask of the matched [Product][google.cloud.retail.v2alpha.Product]
  534. // fields. If matched attributes cannot be determined, this map will be
  535. // empty.
  536. //
  537. // For example, a key "sku1" with field mask
  538. // "products.color_info" indicates there is a match between
  539. // "sku1" [ColorInfo][google.cloud.retail.v2alpha.ColorInfo] and the query.
  540. map<string, google.protobuf.FieldMask> matching_variant_fields = 4;
  541. // The rollup matching
  542. // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT]
  543. // [Product][google.cloud.retail.v2alpha.Product] attributes. The key is one
  544. // of the
  545. // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2alpha.SearchRequest.variant_rollup_keys].
  546. // The values are the merged and de-duplicated
  547. // [Product][google.cloud.retail.v2alpha.Product] attributes. Notice that
  548. // the rollup values are respect filter. For example, when filtering by
  549. // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is
  550. // returned.
  551. //
  552. // For textual and numerical attributes, the rollup values is a list of
  553. // string or double values with type
  554. // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if
  555. // there are two variants with colors "red" and "blue", the rollup values
  556. // are { key: "colorFamilies"
  557. // value {
  558. // list_value {
  559. // values { string_value: "red" }
  560. // values { string_value: "blue" }
  561. // }
  562. // }
  563. // }
  564. //
  565. // For
  566. // [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info],
  567. // the rollup values is a double value with type
  568. // [google.protobuf.Value][google.protobuf.Value]. For example, {key:
  569. // "pickupInStore.store1" value { number_value: 10 }} means a there are 10
  570. // variants in this product are available in the store "store1".
  571. map<string, google.protobuf.Value> variant_rollup_values = 5;
  572. }
  573. // A facet result.
  574. message Facet {
  575. // A facet value which contains value names and their count.
  576. message FacetValue {
  577. // A facet value which contains values.
  578. oneof facet_value {
  579. // Text value of a facet, such as "Black" for facet "colorFamilies".
  580. string value = 1;
  581. // Interval value for a facet, such as [10, 20) for facet "price".
  582. Interval interval = 2;
  583. }
  584. // Number of items that have this facet value.
  585. int64 count = 3;
  586. }
  587. // The key for this facet. E.g., "colorFamilies" or "price" or
  588. // "attributes.attr1".
  589. string key = 1;
  590. // The facet values for this field.
  591. repeated FacetValue values = 2;
  592. // Whether the facet is dynamically generated.
  593. bool dynamic_facet = 3;
  594. }
  595. // Information describing query expansion including whether expansion has
  596. // occurred.
  597. message QueryExpansionInfo {
  598. // Bool describing whether query expansion has occurred.
  599. bool expanded_query = 1;
  600. }
  601. // A list of matched items. The order represents the ranking.
  602. repeated SearchResult results = 1;
  603. // Results of facets requested by user.
  604. repeated Facet facets = 2;
  605. // The estimated total count of matched items irrespective of pagination. The
  606. // count of [results][google.cloud.retail.v2alpha.SearchResponse.results]
  607. // returned by pagination may be less than the
  608. // [total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] that
  609. // matches.
  610. int32 total_size = 3;
  611. // If spell correction applies, the corrected query. Otherwise, empty.
  612. string corrected_query = 4;
  613. // A unique search token. This should be included in the
  614. // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this
  615. // search, which enables accurate attribution of search model performance.
  616. string attribution_token = 5;
  617. // A token that can be sent as
  618. // [SearchRequest.page_token][google.cloud.retail.v2alpha.SearchRequest.page_token]
  619. // to retrieve the next page. If this field is omitted, there are no
  620. // subsequent pages.
  621. string next_page_token = 6;
  622. // Query expansion information for the returned results.
  623. QueryExpansionInfo query_expansion_info = 7;
  624. // The URI of a customer-defined redirect page. If redirect action is
  625. // triggered, no search will be performed, and only
  626. // [redirect_uri][google.cloud.retail.v2alpha.SearchResponse.redirect_uri] and
  627. // [attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token]
  628. // will be set in the response.
  629. string redirect_uri = 10;
  630. }