search method

Performs a search.

This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.

request - The metadata request object.

Request parameters:

placement - Required. The resource name of the Retail Search serving config, such as projects / * /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config or the name of the legacy placement resource, such as projects / * /locations/global/catalogs/default_catalog/placements/default_search. This field is used to identify the serving config name and the set of models that are used to make the search. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/catalogs/\[^/\]+/servingConfigs/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a GoogleCloudRetailV2SearchResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<GoogleCloudRetailV2SearchResponse> search(
  GoogleCloudRetailV2SearchRequest request,
  core.String placement, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v2/' + core.Uri.encodeFull('$placement') + ':search';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return GoogleCloudRetailV2SearchResponse.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}