Discovery Engine V1 API - Class Google::Cloud::DiscoveryEngine::V1::CompletionService::Client (v0.1.0)

Reference documentation and code samples for the Discovery Engine V1 API class Google::Cloud::DiscoveryEngine::V1::CompletionService::Client.

Client for the CompletionService service.

Service for Auto-Completion.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the CompletionService Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all CompletionService clients
::Google::Cloud::DiscoveryEngine::V1::CompletionService::Client.configure do |config|
  config.timeout = 10.0
end

#complete_query

def complete_query(request, options = nil) -> ::Google::Cloud::DiscoveryEngine::V1::CompleteQueryResponse
def complete_query(data_store: nil, query: nil, query_model: nil, user_pseudo_id: nil) -> ::Google::Cloud::DiscoveryEngine::V1::CompleteQueryResponse

Completes the specified user input with keyword suggestions.

Overloads
def complete_query(request, options = nil) -> ::Google::Cloud::DiscoveryEngine::V1::CompleteQueryResponse
Pass arguments to complete_query via a request object, either of type Google::Cloud::DiscoveryEngine::V1::CompleteQueryRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::DiscoveryEngine::V1::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(data_store: nil, query: nil, query_model: nil, user_pseudo_id: nil) -> ::Google::Cloud::DiscoveryEngine::V1::CompleteQueryResponse
Pass arguments to 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).
Parameters
  • data_store (::String) — Required. The parent data store resource name for which the completion is performed, such as projects/*/locations/global/collections/default_collection/dataStores/default_data_store.
  • query (::String) — Required. The typeahead input used to fetch suggestions. Maximum length is 128 characters.
  • query_model (::String) —

    Selects data model of query suggestions for serving. Currently supported values:

    • document - Using suggestions generated from user-imported documents.
    • search-history - Using suggestions generated from the past history of SearchService.Search API calls. Do not use it when there is no traffic for Search API.
    • user-event - Using suggestions generated from user-imported search events.

    Default values:

    • document is the default model for regular dataStores.
    • search-history is the default model for [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1.IndustryVertical.SITE_SEARCH] dataStores.
  • user_pseudo_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.

    This field should NOT have a fixed value such as unknown_visitor.

    This should be the same identifier as UserEvent.user_pseudo_id and SearchRequest.user_pseudo_id.

    The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned.

Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/discovery_engine/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::DiscoveryEngine::V1::CompletionService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::DiscoveryEngine::V1::CompleteQueryRequest.new

# Call the complete_query method.
result = client.complete_query request

# The returned object is of type Google::Cloud::DiscoveryEngine::V1::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.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#initialize

def initialize() { |config| ... } -> Client

Create a new CompletionService client object.

Yields
  • (config) — Configure the CompletionService client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::DiscoveryEngine::V1::CompletionService::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::DiscoveryEngine::V1::CompletionService::Client.new do |config|
  config.timeout = 10.0
end