search_service.proto 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  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/product.proto";
  22. import "google/protobuf/field_mask.proto";
  23. import "google/protobuf/struct.proto";
  24. option csharp_namespace = "Google.Cloud.Retail.V2Beta";
  25. option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail";
  26. option java_multiple_files = true;
  27. option java_outer_classname = "SearchServiceProto";
  28. option java_package = "com.google.cloud.retail.v2beta";
  29. option objc_class_prefix = "RETAIL";
  30. option php_namespace = "Google\\Cloud\\Retail\\V2beta";
  31. option ruby_package = "Google::Cloud::Retail::V2beta";
  32. // Service for search.
  33. //
  34. // This feature is only available for users who have Retail Search enabled.
  35. // Enable Retail Search on Cloud Console before using this feature.
  36. service SearchService {
  37. option (google.api.default_host) = "retail.googleapis.com";
  38. option (google.api.oauth_scopes) =
  39. "https://www.googleapis.com/auth/cloud-platform";
  40. // Performs a search.
  41. //
  42. // This feature is only available for users who have Retail Search enabled.
  43. // Enable Retail Search on Cloud Console before using this feature.
  44. rpc Search(SearchRequest) returns (SearchResponse) {
  45. option (google.api.http) = {
  46. post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:search"
  47. body: "*"
  48. additional_bindings {
  49. post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search"
  50. body: "*"
  51. }
  52. };
  53. }
  54. }
  55. // Request message for
  56. // [SearchService.Search][google.cloud.retail.v2beta.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.v2beta.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.v2beta.SearchRequest.FacetSpec.FacetKey.query]
  69. // is not specified:
  70. //
  71. // * textual_field =
  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. // * "inventory(place_id,attributes.key)"
  94. //
  95. // * numerical_field =
  96. // * "price"
  97. // * "discount"
  98. // * "rating"
  99. // * "ratingCount"
  100. // * "attributes.key"
  101. // * "inventory(place_id,price)"
  102. // * "inventory(place_id,original_price)"
  103. // * "inventory(place_id,attributes.key)"
  104. string key = 1 [(google.api.field_behavior) = REQUIRED];
  105. // Set only if values should be bucketized into intervals. Must be set
  106. // for facets with numerical values. Must not be set for facet with text
  107. // values. Maximum number of intervals is 30.
  108. repeated Interval intervals = 2;
  109. // Only get facet for the given restricted values. For example, when using
  110. // "pickupInStore" as key and set restricted values to
  111. // ["store123", "store456"], only facets for "store123" and "store456" are
  112. // returned. Only supported on predefined textual fields, custom textual
  113. // attributes and fulfillments. Maximum is 20.
  114. //
  115. // Must be set for the fulfillment facet keys:
  116. //
  117. // * pickupInStore
  118. //
  119. // * shipToStore
  120. //
  121. // * sameDayDelivery
  122. //
  123. // * nextDayDelivery
  124. //
  125. // * customFulfillment1
  126. //
  127. // * customFulfillment2
  128. //
  129. // * customFulfillment3
  130. //
  131. // * customFulfillment4
  132. //
  133. // * customFulfillment5
  134. repeated string restricted_values = 3;
  135. // Only get facet values that start with the given string prefix. For
  136. // example, suppose "categories" has three values "Women > Shoe",
  137. // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the
  138. // "categories" facet will give only "Women > Shoe" and "Women > Dress".
  139. // Only supported on textual fields. Maximum is 10.
  140. repeated string prefixes = 8;
  141. // Only get facet values that contains the given strings. For example,
  142. // suppose "categories" has three values "Women > Shoe",
  143. // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the
  144. // "categories" facet will give only "Women > Shoe" and "Men > Shoe".
  145. // Only supported on textual fields. Maximum is 10.
  146. repeated string contains = 9;
  147. // True to make facet keys case insensitive when getting faceting
  148. // values with prefixes or contains; false otherwise.
  149. bool case_insensitive = 10;
  150. // The order in which
  151. // [SearchResponse.Facet.values][google.cloud.retail.v2beta.SearchResponse.Facet.values]
  152. // are returned.
  153. //
  154. // Allowed values are:
  155. //
  156. // * "count desc", which means order by
  157. // [SearchResponse.Facet.values.count][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.count]
  158. // descending.
  159. //
  160. // * "value desc", which means order by
  161. // [SearchResponse.Facet.values.value][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.value]
  162. // descending.
  163. // Only applies to textual facets.
  164. //
  165. // If not set, textual values are sorted in [natural
  166. // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical
  167. // intervals are sorted in the order given by
  168. // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.intervals];
  169. // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]
  170. // are sorted in the order given by
  171. // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.restricted_values].
  172. string order_by = 4;
  173. // The query that is used to compute facet for the given facet key.
  174. // When provided, it will override the default behavior of facet
  175. // computation. The query syntax is the same as a filter expression. See
  176. // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter]
  177. // for detail syntax and limitations. Notice that there is no limitation
  178. // on
  179. // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key]
  180. // when query is specified.
  181. //
  182. // In the response,
  183. // [SearchResponse.Facet.values.value][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.value]
  184. // will be always "1" and
  185. // [SearchResponse.Facet.values.count][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.count]
  186. // will be the number of results that match the query.
  187. //
  188. // For example, you can set a customized facet for "shipToStore",
  189. // where
  190. // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key]
  191. // is "customizedShipToStore", and
  192. // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query]
  193. // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")".
  194. // Then the facet will count the products that are both in stock and ship
  195. // to store "123".
  196. string query = 5;
  197. // Returns the min and max value for each numerical facet intervals.
  198. // Ignored for textual facets.
  199. bool return_min_max = 11;
  200. }
  201. // Required. The facet key specification.
  202. FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED];
  203. // Maximum of facet values that should be returned for this facet. If
  204. // unspecified, defaults to 20. The maximum allowed value is 300. Values
  205. // above 300 will be coerced to 300.
  206. //
  207. // If this field is negative, an INVALID_ARGUMENT is returned.
  208. int32 limit = 2;
  209. // List of keys to exclude when faceting.
  210. //
  211. //
  212. // By default,
  213. // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key]
  214. // is not excluded from the filter unless it is listed in this field.
  215. //
  216. // Listing a facet key in this field allows its values to appear as facet
  217. // results, even when they are filtered out of search results. Using this
  218. // field does not affect what search results are returned.
  219. //
  220. // For example, suppose there are 100 products with the color facet "Red"
  221. // and 200 products with the color facet "Blue". A query containing the
  222. // filter "colorFamilies:ANY("Red")" and having "colorFamilies" as
  223. // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key]
  224. // would by default return only "Red" products in the search results, and
  225. // also return "Red" with count 100 as the only color facet. Although there
  226. // are also blue products available, "Blue" would not be shown as an
  227. // available facet value.
  228. //
  229. // If "colorFamilies" is listed in "excludedFilterKeys", then the query
  230. // returns the facet values "Red" with count 100 and "Blue" with count
  231. // 200, because the "colorFamilies" key is now excluded from the filter.
  232. // Because this field doesn't affect search results, the search results
  233. // are still correctly filtered to return only "Red" products.
  234. //
  235. // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error
  236. // is returned.
  237. repeated string excluded_filter_keys = 3;
  238. // Enables dynamic position for this facet. If set to true, the position of
  239. // this facet among all facets in the response is determined by Google
  240. // Retail Search. It will be ordered together with dynamic facets if dynamic
  241. // facets is enabled. If set to false, the position of this facet in the
  242. // response will be the same as in the request, and it will be ranked before
  243. // the facets with dynamic position enable and all dynamic facets.
  244. //
  245. // For example, you may always want to have rating facet returned in
  246. // the response, but it's not necessarily to always display the rating facet
  247. // at the top. In that case, you can set enable_dynamic_position to true so
  248. // that the position of rating facet in response will be determined by
  249. // Google Retail Search.
  250. //
  251. // Another example, assuming you have the following facets in the request:
  252. //
  253. // * "rating", enable_dynamic_position = true
  254. //
  255. // * "price", enable_dynamic_position = false
  256. //
  257. // * "brands", enable_dynamic_position = false
  258. //
  259. // And also you have a dynamic facets enable, which will generate a facet
  260. // 'gender'. Then the final order of the facets in the response can be
  261. // ("price", "brands", "rating", "gender") or ("price", "brands", "gender",
  262. // "rating") depends on how Google Retail Search orders "gender" and
  263. // "rating" facets. However, notice that "price" and "brands" will always be
  264. // ranked at 1st and 2nd position since their enable_dynamic_position are
  265. // false.
  266. bool enable_dynamic_position = 4;
  267. }
  268. // The specifications of dynamically generated facets.
  269. message DynamicFacetSpec {
  270. // Enum to control DynamicFacet mode
  271. enum Mode {
  272. // Default value.
  273. MODE_UNSPECIFIED = 0;
  274. // Disable Dynamic Facet.
  275. DISABLED = 1;
  276. // Automatic mode built by Google Retail Search.
  277. ENABLED = 2;
  278. }
  279. // Mode of the DynamicFacet feature.
  280. // Defaults to
  281. // [Mode.DISABLED][google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode.DISABLED]
  282. // if it's unset.
  283. Mode mode = 1;
  284. }
  285. // Boost specification to boost certain items.
  286. message BoostSpec {
  287. // Boost applies to products which match a condition.
  288. message ConditionBoostSpec {
  289. // An expression which specifies a boost condition. The syntax and
  290. // supported fields are the same as a filter expression. See
  291. // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter]
  292. // for detail syntax and limitations.
  293. //
  294. // Examples:
  295. //
  296. // * To boost products with product ID "product_1" or "product_2", and
  297. // color
  298. // "Red" or "Blue":
  299. // * (id: ANY("product_1", "product_2")) AND (colorFamilies:
  300. // ANY("Red","Blue"))
  301. string condition = 1;
  302. // Strength of the condition boost, which should be in [-1, 1]. Negative
  303. // boost means demotion. Default is 0.0.
  304. //
  305. // Setting to 1.0 gives the item a big promotion. However, it does not
  306. // necessarily mean that the boosted item will be the top result at all
  307. // times, nor that other items will be excluded. Results could still be
  308. // shown even when none of them matches the condition. And results that
  309. // are significantly more relevant to the search query can still trump
  310. // your heavily favored but irrelevant items.
  311. //
  312. // Setting to -1.0 gives the item a big demotion. However, results that
  313. // are deeply relevant might still be shown. The item will have an
  314. // upstream battle to get a fairly high ranking, but it is not blocked out
  315. // completely.
  316. //
  317. // Setting to 0.0 means no boost applied. The boosting condition is
  318. // ignored.
  319. float boost = 2;
  320. }
  321. // Condition boost specifications. If a product matches multiple conditions
  322. // in the specifictions, boost scores from these specifications are all
  323. // applied and combined in a non-linear way. Maximum number of
  324. // specifications is 20.
  325. repeated ConditionBoostSpec condition_boost_specs = 1;
  326. // Whether to skip boostspec validation. If this field is set to true,
  327. // invalid
  328. // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs]
  329. // will be ignored and valid
  330. // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs]
  331. // will still be applied.
  332. optional bool skip_boost_spec_validation = 2;
  333. }
  334. // Specification to determine under which conditions query expansion should
  335. // occur.
  336. message QueryExpansionSpec {
  337. // Enum describing under which condition query expansion should occur.
  338. enum Condition {
  339. // Unspecified query expansion condition. In this case, server behavior
  340. // defaults to
  341. // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED].
  342. CONDITION_UNSPECIFIED = 0;
  343. // Disabled query expansion. Only the exact search query is used, even if
  344. // [SearchResponse.total_size][google.cloud.retail.v2beta.SearchResponse.total_size]
  345. // is zero.
  346. DISABLED = 1;
  347. // Automatic query expansion built by Google Retail Search.
  348. AUTO = 3;
  349. }
  350. // The condition under which query expansion should occur. Default to
  351. // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED].
  352. Condition condition = 1;
  353. // Whether to pin unexpanded results. If this field is set to true,
  354. // unexpanded products are always at the top of the search results, followed
  355. // by the expanded results.
  356. bool pin_unexpanded_results = 2;
  357. }
  358. // The specification for personalization.
  359. message PersonalizationSpec {
  360. // The personalization mode of each search request.
  361. enum Mode {
  362. // Default value. In this case, server behavior defaults to
  363. // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO].
  364. MODE_UNSPECIFIED = 0;
  365. // Let CRS decide whether to use personalization based on quality of user
  366. // event data.
  367. AUTO = 1;
  368. // Disable personalization.
  369. DISABLED = 2;
  370. }
  371. // Defaults to
  372. // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO].
  373. Mode mode = 1;
  374. }
  375. // The specification for query spell correction.
  376. message SpellCorrectionSpec {
  377. // Enum describing under which mode spell correction should occur.
  378. enum Mode {
  379. // Unspecified spell correction mode. In this case, server behavior
  380. // defaults to
  381. // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO].
  382. MODE_UNSPECIFIED = 0;
  383. // Google Retail Search will try to find a spell suggestion if there
  384. // is any and put in the
  385. // [SearchResponse.corrected_query][google.cloud.retail.v2beta.SearchResponse.corrected_query].
  386. // The spell suggestion will not be used as the search query.
  387. SUGGESTION_ONLY = 1;
  388. // Automatic spell correction built by Google Retail Search. Search will
  389. // be based on the corrected query if found.
  390. AUTO = 2;
  391. }
  392. // The mode under which spell correction should take effect to
  393. // replace the original search query. Default to
  394. // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO].
  395. Mode mode = 1;
  396. }
  397. // The search mode of each search request.
  398. enum SearchMode {
  399. // Default value. In this case both product search and faceted search will
  400. // be performed. Both
  401. // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult]
  402. // and
  403. // [SearchResponse.Facet][google.cloud.retail.v2beta.SearchResponse.Facet]
  404. // will be returned.
  405. SEARCH_MODE_UNSPECIFIED = 0;
  406. // Only product search will be performed. The faceted search will be
  407. // disabled.
  408. //
  409. // Only
  410. // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult]
  411. // will be returned.
  412. // [SearchResponse.Facet][google.cloud.retail.v2beta.SearchResponse.Facet]
  413. // will not be returned, even if
  414. // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs]
  415. // or
  416. // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec]
  417. // is set.
  418. PRODUCT_SEARCH_ONLY = 1;
  419. // Only faceted search will be performed. The product search will be
  420. // disabled.
  421. //
  422. // When in this mode, one or both of
  423. // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs]
  424. // and
  425. // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec]
  426. // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only
  427. // [SearchResponse.Facet][google.cloud.retail.v2beta.SearchResponse.Facet]
  428. // will be returned.
  429. // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult]
  430. // will not be returned.
  431. FACETED_SEARCH_ONLY = 2;
  432. }
  433. // Required. The resource name of the Retail Search serving config, such as
  434. // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config`
  435. // or the name of the legacy placement resource, such as
  436. // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`.
  437. // This field is used to identify the serving configuration name and the set
  438. // of models that will be used to make the search.
  439. string placement = 1 [(google.api.field_behavior) = REQUIRED];
  440. // The branch resource name, such as
  441. // `projects/*/locations/global/catalogs/default_catalog/branches/0`.
  442. //
  443. // Use "default_branch" as the branch ID or leave this field empty, to search
  444. // products under the default branch.
  445. string branch = 2 [
  446. (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" }
  447. ];
  448. // Raw search query.
  449. //
  450. // If this field is empty, the request is considered a category browsing
  451. // request and returned results are based on
  452. // [filter][google.cloud.retail.v2beta.SearchRequest.filter] and
  453. // [page_categories][google.cloud.retail.v2beta.SearchRequest.page_categories].
  454. string query = 3;
  455. // Required. A unique identifier for tracking visitors. For example, this
  456. // could be implemented with an HTTP cookie, which should be able to uniquely
  457. // identify a visitor on a single device. This unique identifier should not
  458. // change if the visitor logs in or out of the website.
  459. //
  460. // This should be the same identifier as
  461. // [UserEvent.visitor_id][google.cloud.retail.v2beta.UserEvent.visitor_id].
  462. //
  463. // The field must be a UTF-8 encoded string with a length limit of 128
  464. // characters. Otherwise, an INVALID_ARGUMENT error is returned.
  465. string visitor_id = 4 [(google.api.field_behavior) = REQUIRED];
  466. // User information.
  467. UserInfo user_info = 5;
  468. // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return.
  469. // If unspecified, defaults to a reasonable value. The maximum allowed value
  470. // is 120. Values above 120 will be coerced to 120.
  471. //
  472. // If this field is negative, an INVALID_ARGUMENT is returned.
  473. int32 page_size = 7;
  474. // A page token
  475. // [SearchResponse.next_page_token][google.cloud.retail.v2beta.SearchResponse.next_page_token],
  476. // received from a previous
  477. // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]
  478. // call. Provide this to retrieve the subsequent page.
  479. //
  480. // When paginating, all other parameters provided to
  481. // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]
  482. // must match the call that provided the page token. Otherwise, an
  483. // INVALID_ARGUMENT error is returned.
  484. string page_token = 8;
  485. // A 0-indexed integer that specifies the current offset (that is, starting
  486. // result location, amongst the [Product][google.cloud.retail.v2beta.Product]s
  487. // deemed by the API as relevant) in search results. This field is only
  488. // considered if
  489. // [page_token][google.cloud.retail.v2beta.SearchRequest.page_token] is unset.
  490. //
  491. // If this field is negative, an INVALID_ARGUMENT is returned.
  492. int32 offset = 9;
  493. // The filter syntax consists of an expression language for constructing a
  494. // predicate from one or more fields of the products being filtered. Filter
  495. // expression is case-sensitive. See more details at this [user
  496. // guide](https://cloud.google.com/retail/docs/filter-and-order#filter).
  497. //
  498. // If this field is unrecognizable, an INVALID_ARGUMENT is returned.
  499. string filter = 10;
  500. // The default filter that is applied when a user performs a search without
  501. // checking any filters on the search page.
  502. //
  503. // The filter applied to every search request when quality improvement such as
  504. // query expansion is needed. For example, if a query does not have enough
  505. // results, an expanded query with
  506. // [SearchRequest.canonical_filter][google.cloud.retail.v2beta.SearchRequest.canonical_filter]
  507. // will be returned as a supplement of the original query. This field is
  508. // strongly recommended to achieve high search quality.
  509. //
  510. // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter]
  511. // for more details about filter syntax.
  512. string canonical_filter = 28;
  513. // The order in which products are returned. Products can be ordered by
  514. // a field in an [Product][google.cloud.retail.v2beta.Product] object. Leave
  515. // it unset if ordered by relevance. OrderBy expression is case-sensitive. See
  516. // more details at this [user
  517. // guide](https://cloud.google.com/retail/docs/filter-and-order#order).
  518. //
  519. // If this field is unrecognizable, an INVALID_ARGUMENT is returned.
  520. string order_by = 11;
  521. // Facet specifications for faceted search. If empty, no facets are returned.
  522. //
  523. // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error
  524. // is returned.
  525. repeated FacetSpec facet_specs = 12;
  526. // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic
  527. // to enable dynamic facets. Do not set this field.
  528. //
  529. // The specification for dynamically generated facets. Notice that only
  530. // textual facets can be dynamically generated.
  531. DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true];
  532. // Boost specification to boost certain products. See more details at this
  533. // [user guide](https://cloud.google.com/retail/docs/boosting).
  534. //
  535. // Notice that if both
  536. // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids]
  537. // and
  538. // [SearchRequest.boost_spec][google.cloud.retail.v2beta.SearchRequest.boost_spec]
  539. // are set, the boost conditions from both places are evaluated. If a search
  540. // request matches multiple boost conditions, the final boost score is equal
  541. // to the sum of the boost scores from all matched boost conditions.
  542. BoostSpec boost_spec = 13;
  543. // The query expansion specification that specifies the conditions under which
  544. // query expansion will occur. See more details at this [user
  545. // guide](https://cloud.google.com/retail/docs/result-size#query_expansion).
  546. QueryExpansionSpec query_expansion_spec = 14;
  547. // The keys to fetch and rollup the matching
  548. // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT]
  549. // [Product][google.cloud.retail.v2beta.Product]s attributes,
  550. // [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo] or
  551. // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s attributes.
  552. // The attributes from all the matching
  553. // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT]
  554. // [Product][google.cloud.retail.v2beta.Product]s or
  555. // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s are merged and
  556. // de-duplicated. Notice that rollup attributes will lead to extra query
  557. // latency. Maximum number of keys is 30.
  558. //
  559. // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], a
  560. // fulfillment type and a fulfillment ID must be provided in the format of
  561. // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123",
  562. // "pickupInStore" is fulfillment type and "store123" is the store ID.
  563. //
  564. // Supported keys are:
  565. //
  566. // * colorFamilies
  567. // * price
  568. // * originalPrice
  569. // * discount
  570. // * variantId
  571. // * inventory(place_id,price)
  572. // * inventory(place_id,original_price)
  573. // * inventory(place_id,attributes.key), where key is any key in the
  574. // [Product.local_inventories.attributes][google.cloud.retail.v2beta.LocalInventory.attributes]
  575. // map.
  576. // * attributes.key, where key is any key in the
  577. // [Product.attributes][google.cloud.retail.v2beta.Product.attributes] map.
  578. // * pickupInStore.id, where id is any
  579. // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]
  580. // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]
  581. // "pickup-in-store".
  582. // * shipToStore.id, where id is any
  583. // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]
  584. // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]
  585. // "ship-to-store".
  586. // * sameDayDelivery.id, where id is any
  587. // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]
  588. // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]
  589. // "same-day-delivery".
  590. // * nextDayDelivery.id, where id is any
  591. // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]
  592. // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]
  593. // "next-day-delivery".
  594. // * customFulfillment1.id, where id is any
  595. // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]
  596. // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]
  597. // "custom-type-1".
  598. // * customFulfillment2.id, where id is any
  599. // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]
  600. // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]
  601. // "custom-type-2".
  602. // * customFulfillment3.id, where id is any
  603. // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]
  604. // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]
  605. // "custom-type-3".
  606. // * customFulfillment4.id, where id is any
  607. // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]
  608. // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]
  609. // "custom-type-4".
  610. // * customFulfillment5.id, where id is any
  611. // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]
  612. // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]
  613. // "custom-type-5".
  614. //
  615. // If this field is set to an invalid value other than these, an
  616. // INVALID_ARGUMENT error is returned.
  617. repeated string variant_rollup_keys = 17;
  618. // The categories associated with a category page. Required for category
  619. // navigation queries to achieve good search quality. The format should be
  620. // the same as
  621. // [UserEvent.page_categories][google.cloud.retail.v2beta.UserEvent.page_categories];
  622. //
  623. // To represent full path of category, use '>' sign to separate different
  624. // hierarchies. If '>' is part of the category name, replace it with
  625. // other character(s).
  626. //
  627. // Category pages include special pages such as sales or promotions. For
  628. // instance, a special sale page may have the category hierarchy:
  629. // "pageCategories" : ["Sales > 2017 Black Friday Deals"].
  630. repeated string page_categories = 23;
  631. // The search mode of the search request. If not specified, a single search
  632. // request triggers both product search and faceted search.
  633. SearchMode search_mode = 31;
  634. // The specification for personalization.
  635. //
  636. // Notice that if both
  637. // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec]
  638. // and
  639. // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec]
  640. // are set.
  641. // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec]
  642. // will override
  643. // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec].
  644. PersonalizationSpec personalization_spec = 32;
  645. // The labels applied to a resource must meet the following requirements:
  646. //
  647. // * Each resource can have multiple labels, up to a maximum of 64.
  648. // * Each label must be a key-value pair.
  649. // * Keys have a minimum length of 1 character and a maximum length of 63
  650. // characters and cannot be empty. Values can be empty and have a maximum
  651. // length of 63 characters.
  652. // * Keys and values can contain only lowercase letters, numeric characters,
  653. // underscores, and dashes. All characters must use UTF-8 encoding, and
  654. // international characters are allowed.
  655. // * The key portion of a label must be unique. However, you can use the same
  656. // key with multiple resources.
  657. // * Keys must start with a lowercase letter or international character.
  658. //
  659. // See [Google Cloud
  660. // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
  661. // for more details.
  662. map<string, string> labels = 34;
  663. // The spell correction specification that specifies the mode under
  664. // which spell correction will take effect.
  665. optional SpellCorrectionSpec spell_correction_spec = 35;
  666. }
  667. // Response message for
  668. // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]
  669. // method.
  670. message SearchResponse {
  671. // Represents the search results.
  672. message SearchResult {
  673. // [Product.id][google.cloud.retail.v2beta.Product.id] of the searched
  674. // [Product][google.cloud.retail.v2beta.Product].
  675. string id = 1;
  676. // The product data snippet in the search response. Only
  677. // [Product.name][google.cloud.retail.v2beta.Product.name] is guaranteed to
  678. // be populated.
  679. //
  680. // [Product.variants][google.cloud.retail.v2beta.Product.variants] contains
  681. // the product variants that match the search query. If there are multiple
  682. // product variants matching the query, top 5 most relevant product variants
  683. // are returned and ordered by relevancy.
  684. //
  685. // If relevancy can be deternmined, use
  686. // [matching_variant_fields][google.cloud.retail.v2beta.SearchResponse.SearchResult.matching_variant_fields]
  687. // to look up matched product variants fields. If relevancy cannot be
  688. // determined, e.g. when searching "shoe" all products in a shoe product can
  689. // be a match, 5 product variants are returned but order is meaningless.
  690. Product product = 2;
  691. // The count of matched
  692. // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT]
  693. // [Product][google.cloud.retail.v2beta.Product]s.
  694. int32 matching_variant_count = 3;
  695. // If a [variant][google.cloud.retail.v2beta.Product.Type.VARIANT]
  696. // [Product][google.cloud.retail.v2beta.Product] matches the search query,
  697. // this map indicates which [Product][google.cloud.retail.v2beta.Product]
  698. // fields are matched. The key is the
  699. // [Product.name][google.cloud.retail.v2beta.Product.name], the value is a
  700. // field mask of the matched [Product][google.cloud.retail.v2beta.Product]
  701. // fields. If matched attributes cannot be determined, this map will be
  702. // empty.
  703. //
  704. // For example, a key "sku1" with field mask
  705. // "products.color_info" indicates there is a match between
  706. // "sku1" [ColorInfo][google.cloud.retail.v2beta.ColorInfo] and the query.
  707. map<string, google.protobuf.FieldMask> matching_variant_fields = 4;
  708. // The rollup matching
  709. // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT]
  710. // [Product][google.cloud.retail.v2beta.Product] attributes. The key is one
  711. // of the
  712. // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2beta.SearchRequest.variant_rollup_keys].
  713. // The values are the merged and de-duplicated
  714. // [Product][google.cloud.retail.v2beta.Product] attributes. Notice that the
  715. // rollup values are respect filter. For example, when filtering by
  716. // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is
  717. // returned.
  718. //
  719. // For textual and numerical attributes, the rollup values is a list of
  720. // string or double values with type
  721. // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if
  722. // there are two variants with colors "red" and "blue", the rollup values
  723. // are
  724. //
  725. // { key: "colorFamilies"
  726. // value {
  727. // list_value {
  728. // values { string_value: "red" }
  729. // values { string_value: "blue" }
  730. // }
  731. // }
  732. // }
  733. //
  734. // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], the
  735. // rollup values is a double value with type
  736. // [google.protobuf.Value][google.protobuf.Value]. For example,
  737. // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there
  738. // are 10 variants in this product are available in the store "store1".
  739. map<string, google.protobuf.Value> variant_rollup_values = 5;
  740. // Specifies previous events related to this product for this user based on
  741. // [UserEvent][google.cloud.retail.v2beta.UserEvent] with same
  742. // [SearchRequest.visitor_id][google.cloud.retail.v2beta.SearchRequest.visitor_id]
  743. // or [UserInfo.user_id][google.cloud.retail.v2beta.UserInfo.user_id].
  744. //
  745. // This is set only when
  746. // [SearchRequest.PersonalizationSpec.mode][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.mode]
  747. // is
  748. // [SearchRequest.PersonalizationSpec.Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO].
  749. //
  750. // Possible values:
  751. //
  752. // * `purchased`: Indicates that this product has been purchased before.
  753. repeated string personal_labels = 7;
  754. }
  755. // A facet result.
  756. message Facet {
  757. // A facet value which contains value names and their count.
  758. message FacetValue {
  759. // A facet value which contains values.
  760. oneof facet_value {
  761. // Text value of a facet, such as "Black" for facet "colorFamilies".
  762. string value = 1;
  763. // Interval value for a facet, such as [10, 20) for facet "price".
  764. Interval interval = 2;
  765. }
  766. // Number of items that have this facet value.
  767. int64 count = 3;
  768. // The minimum value in the
  769. // [FacetValue.interval][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.interval].
  770. // Only supported on numerical facets and returned if
  771. // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.return_min_max]
  772. // is true.
  773. double min_value = 5;
  774. // The maximum value in the
  775. // [FacetValue.interval][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.interval].
  776. // Only supported on numerical facets and returned if
  777. // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.return_min_max]
  778. // is true.
  779. double max_value = 6;
  780. }
  781. // The key for this facet. E.g., "colorFamilies" or "price" or
  782. // "attributes.attr1".
  783. string key = 1;
  784. // The facet values for this field.
  785. repeated FacetValue values = 2;
  786. // Whether the facet is dynamically generated.
  787. bool dynamic_facet = 3;
  788. }
  789. // Information describing query expansion including whether expansion has
  790. // occurred.
  791. message QueryExpansionInfo {
  792. // Bool describing whether query expansion has occurred.
  793. bool expanded_query = 1;
  794. // Number of pinned results. This field will only be set when expansion
  795. // happens and
  796. // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.pin_unexpanded_results]
  797. // is set to true.
  798. int64 pinned_result_count = 2;
  799. }
  800. // A list of matched items. The order represents the ranking.
  801. repeated SearchResult results = 1;
  802. // Results of facets requested by user.
  803. repeated Facet facets = 2;
  804. // The estimated total count of matched items irrespective of pagination. The
  805. // count of [results][google.cloud.retail.v2beta.SearchResponse.results]
  806. // returned by pagination may be less than the
  807. // [total_size][google.cloud.retail.v2beta.SearchResponse.total_size] that
  808. // matches.
  809. int32 total_size = 3;
  810. // Contains the spell corrected query, if found. If the spell correction type
  811. // is AUTOMATIC, then the search results are based on corrected_query.
  812. // Otherwise the original query is used for search.
  813. string corrected_query = 4;
  814. // A unique search token. This should be included in the
  815. // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this
  816. // search, which enables accurate attribution of search model performance.
  817. string attribution_token = 5;
  818. // A token that can be sent as
  819. // [SearchRequest.page_token][google.cloud.retail.v2beta.SearchRequest.page_token]
  820. // to retrieve the next page. If this field is omitted, there are no
  821. // subsequent pages.
  822. string next_page_token = 6;
  823. // Query expansion information for the returned results.
  824. QueryExpansionInfo query_expansion_info = 7;
  825. // The URI of a customer-defined redirect page. If redirect action is
  826. // triggered, no search is performed, and only
  827. // [redirect_uri][google.cloud.retail.v2beta.SearchResponse.redirect_uri] and
  828. // [attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token]
  829. // are set in the response.
  830. string redirect_uri = 10;
  831. // The fully qualified resource name of applied
  832. // [controls](https://cloud.google.com/retail/docs/serving-control-rules).
  833. repeated string applied_controls = 12;
  834. // The invalid
  835. // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs]
  836. // that are not applied during serving.
  837. repeated SearchRequest.BoostSpec.ConditionBoostSpec
  838. invalid_condition_boost_specs = 14;
  839. }