Client for the CompletionService service.
Auto-completion service for retail.
This feature is only available for users who have Retail Search enabled. Please submit a form here to contact cloud sales if you are interested in using Retail Search.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the CompletionService Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all CompletionService clients ::Google::Cloud::Retail::V2::CompletionService::Client.configure do |config| config.timeout = 10.0 end
#complete_query
def complete_query(request, options = nil) -> ::Google::Cloud::Retail::V2::CompleteQueryResponse
def complete_query(catalog: nil, query: nil, visitor_id: nil, language_codes: nil, device_type: nil, dataset: nil, max_suggestions: nil) -> ::Google::Cloud::Retail::V2::CompleteQueryResponse
Completes the specified prefix with keyword suggestions.
This feature is only available for users who have Retail Search enabled. Please submit a form here to contact cloud sales if you are interested in using Retail Search.
def complete_query(request, options = nil) -> ::Google::Cloud::Retail::V2::CompleteQueryResponse
complete_query
via a request object, either of type
Google::Cloud::Retail::V2::CompleteQueryRequest or an equivalent Hash.
- request (::Google::Cloud::Retail::V2::CompleteQueryRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def complete_query(catalog: nil, query: nil, visitor_id: nil, language_codes: nil, device_type: nil, dataset: nil, max_suggestions: nil) -> ::Google::Cloud::Retail::V2::CompleteQueryResponse
complete_query
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
catalog (::String) — Required. Catalog for which the completion is performed.
Full resource name of catalog, such as
projects/*/locations/global/catalogs/default_catalog
. -
query (::String) — Required. The query used to generate suggestions.
The maximum number of allowed characters is 255.
-
visitor_id (::String) — A unique identifier for tracking visitors. For example, this could be
implemented with an HTTP cookie, which should be able to uniquely identify
a visitor on a single device. This unique identifier should not change if
the visitor logs in or out of the website.
The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned.
-
language_codes (::Array<::String>) — The list of languages of the query. This is
the BCP-47 language code, such as "en-US" or "sr-Latn".
For more information, see
Tags for Identifying Languages.
The maximum number of allowed characters is 255. Only "en-US" is currently supported.
-
device_type (::String) —
The device type context for completion suggestions. It is useful to apply different suggestions on different device types, e.g.
DESKTOP
,MOBILE
. If it is empty, the suggestions are across all device types.Supported formats:
UNKNOWN_DEVICE_TYPE
DESKTOP
MOBILE
A customized string starts with
OTHER_
, e.g.OTHER_IPHONE
.
-
dataset (::String) —
Determines which dataset to use for fetching completion. "user-data" will use the imported dataset through CompletionService.ImportCompletionData. "cloud-retail" will use the dataset generated by cloud retail based on user events. If leave empty, it will use the "user-data".
Current supported values:
user-data
cloud-retail This option requires additional allowlisting. Before using cloud-retail, contact Cloud Retail support team first.
-
max_suggestions (::Integer) — Completion max suggestions. If left unset or set to 0, then will fallback
to the configured value [CompletionConfig.max_suggestions][].
The maximum allowed max suggestions is 20. If it is set higher, it will be capped by 20.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Retail::V2::CompleteQueryResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/retail/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Retail::V2::CompletionService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Retail::V2::CompleteQueryRequest.new # Call the complete_query method. result = client.complete_query request # The returned object is of type Google::Cloud::Retail::V2::CompleteQueryResponse. p result
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the CompletionService Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#import_completion_data
def import_completion_data(request, options = nil) -> ::Gapic::Operation
def import_completion_data(parent: nil, input_config: nil, notification_pubsub_topic: nil) -> ::Gapic::Operation
Bulk import of processed completion dataset.
Request processing may be synchronous. Partial updating is not supported.
This feature is only available for users who have Retail Search enabled. Please submit a form here to contact cloud sales if you are interested in using Retail Search.
def import_completion_data(request, options = nil) -> ::Gapic::Operation
import_completion_data
via a request object, either of type
ImportCompletionDataRequest or an equivalent Hash.
- request (::Google::Cloud::Retail::V2::ImportCompletionDataRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def import_completion_data(parent: nil, input_config: nil, notification_pubsub_topic: nil) -> ::Gapic::Operation
import_completion_data
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Required. The catalog which the suggestions dataset belongs to.
Format:
projects/1234/locations/global/catalogs/default_catalog
. - input_config (::Google::Cloud::Retail::V2::CompletionDataInputConfig, ::Hash) — Required. The desired input location of the data.
-
notification_pubsub_topic (::String) — Pub/Sub topic for receiving notification. If this field is set,
when the import is finished, a notification will be sent to
specified Pub/Sub topic. The message data will be JSON string of a
Operation.
Format of the Pub/Sub topic is
projects/{project}/topics/{topic}
.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/retail/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Retail::V2::CompletionService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Retail::V2::ImportCompletionDataRequest.new # Call the import_completion_data method. result = client.import_completion_data request # The returned object is of type Gapic::Operation. You can use this # object to check the status of an operation, cancel it, or wait # for results. Here is how to block until completion: result.wait_until_done! timeout: 60 if result.response? p result.response else puts "Error!" end
#initialize
def initialize() { |config| ... } -> Client
Create a new CompletionService client object.
- (config) — Configure the CompletionService client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::Retail::V2::CompletionService::Client.new # Create a client using a custom configuration client = ::Google::Cloud::Retail::V2::CompletionService::Client.new do |config| config.timeout = 10.0 end
#operations_client
def operations_client() -> ::Google::Cloud::Retail::V2::CompletionService::Operations
Get the associated client for long-running operations.