You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gem name and version: google-cloud-discovery_engine-v1 (0.7.0)
Code example
# document: https://cloud.google.com/ruby/docs/reference/google-cloud-discovery_engine-v1/0.1.0require'google/cloud/discovery_engine/v1'classVertexAIRepositoryclass << selfdefsearch_event_ids(search_query:)client=initialize_search_clientrequest=build_search_request(search_query:)fetch_event_ids_from_vertex_ai(client:,request:)endprivatedefinitialize_search_clientservice_account_creds=ENV.fetch('GOOGLE_CLOUD_CREDENTIALS')beginsecret_data=JSON.parse(service_account_creds)rescueJSON::ParserError=>eraise"Error parsing JSON secret string: #{e.message}"endGoogle::Cloud::DiscoveryEngine::V1::DocumentService::Client.configuredo |config|
config.credentials=Google::Auth::Credentials.new(secret_data)endGoogle::Cloud::DiscoveryEngine::V1::SearchService::Client.newenddefbuild_search_request(search_query:)gcp_project_id=ENV.fetch('GOOGLE_CLOUD_PROJECT_ID')vertex_ai_engine_id=ENV.fetch('VERTEX_AI_ENGINE_ID')serving_config="projects/#{gcp_project_id}/locations/global/collections/default_collection/engines/#{vertex_ai_engine_id}/servingConfigs/default_config"content_search_spec=Google::Cloud::DiscoveryEngine::V1::SearchRequest::ContentSearchSpec.new(snippet_spec: Google::Cloud::DiscoveryEngine::V1::SearchRequest::ContentSearchSpec::SnippetSpec.new# NOTE: summary spec is not currently supproted for Ruby sdk.)# Create a request. To set request fields, pass in keyword arguments.Google::Cloud::DiscoveryEngine::V1::SearchRequest.new(serving_config:,query: search_query,page_size: 10,content_search_spec:
)enddeffetch_event_ids_from_vertex_ai(client:,request:)event_ids=[]beginresult=client.searchrequestresult.eachdo |item|
event_ids.push(item.to_h[:id])endevent_idsrescueGoogle::Cloud::Error=>eRails.logger.errore.messageSentry.capture_message(e.message)endevent_idsendendend
Then, I checked cloud logging and there were many GRPC request per single call of the above code.
My guess is that if there are 50 search results for page_size=10, the number of GRPCs would be 50/10 = 5 times. If this guess is correct, is this the expected behavior and what should I do to reduce the number of requests?
The text was updated successfully, but these errors were encountered:
Environment details
google-cloud-discovery_engine-v1 (0.7.0)
Code example
Then, I checked cloud logging and there were many GRPC request per single call of the above code.
My guess is that if there are 50 search results for page_size=10, the number of GRPCs would be 50/10 = 5 times. If this guess is correct, is this the expected behavior and what should I do to reduce the number of requests?
The text was updated successfully, but these errors were encountered: