search_service.proto 39 KB

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