Skip to content

Commit

Permalink
feat: add lite search API to allow public website search with API key (
Browse files Browse the repository at this point in the history
…#27495)

feat: add LOW_GROUNDED_ANSWER in answer skip reasons
feat: support query regex in control match rules
docs: keep the API doc up-to-date with recent changes
chore: add selective gapic generation option for publishing
  • Loading branch information
gcf-owl-bot[bot] authored Oct 25, 2024
1 parent ef9f5a2 commit f405b9a
Show file tree
Hide file tree
Showing 17 changed files with 1,042 additions and 4 deletions.
1 change: 1 addition & 0 deletions google-cloud-discovery_engine-v1/.owlbot-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@
"snippets/schema_service/list_schemas.rb",
"snippets/schema_service/update_schema.rb",
"snippets/search_service/search.rb",
"snippets/search_service/search_lite.rb",
"snippets/search_tuning_service/list_custom_models.rb",
"snippets/search_tuning_service/train_custom_model.rb",
"snippets/site_search_engine_service/batch_create_target_sites.rb",
Expand Down
5 changes: 5 additions & 0 deletions google-cloud-discovery_engine-v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
"methods": [
"search"
]
},
"SearchLite": {
"methods": [
"search_lite"
]
}
}
}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,44 @@ def search request_pb, options = nil
result
end

##
# Baseline implementation for the search_lite REST call
#
# @param request_pb [::Google::Cloud::DiscoveryEngine::V1::SearchRequest]
# A request object representing the call parameters. Required.
# @param options [::Gapic::CallOptions]
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
#
# @yield [result, operation] Access the result along with the TransportOperation object
# @yieldparam result [::Google::Cloud::DiscoveryEngine::V1::SearchResponse]
# @yieldparam operation [::Gapic::Rest::TransportOperation]
#
# @return [::Google::Cloud::DiscoveryEngine::V1::SearchResponse]
# A result object deserialized from the server's reply
def search_lite request_pb, options = nil
raise ::ArgumentError, "request must be provided" if request_pb.nil?

verb, uri, query_string_params, body = ServiceStub.transcode_search_lite_request request_pb
query_string_params = if query_string_params.any?
query_string_params.to_h { |p| p.split "=", 2 }
else
{}
end

response = @client_stub.make_http_request(
verb,
uri: uri,
body: body || "",
params: query_string_params,
options: options
)
operation = ::Gapic::Rest::TransportOperation.new response
result = ::Google::Cloud::DiscoveryEngine::V1::SearchResponse.decode_json response.body, ignore_unknown_fields: true

yield result, operation if block_given?
result
end

##
# @private
#
Expand Down Expand Up @@ -136,6 +174,44 @@ def self.transcode_search_request request_pb
)
transcoder.transcode request_pb
end

##
# @private
#
# GRPC transcoding helper method for the search_lite REST call
#
# @param request_pb [::Google::Cloud::DiscoveryEngine::V1::SearchRequest]
# A request object representing the call parameters. Required.
# @return [Array(String, [String, nil], Hash{String => String})]
# Uri, Body, Query string parameters
def self.transcode_search_lite_request request_pb
transcoder = Gapic::Rest::GrpcTranscoder.new
.with_bindings(
uri_method: :post,
uri_template: "/v1/{serving_config}:searchLite",
body: "*",
matches: [
["serving_config", %r{^projects/[^/]+/locations/[^/]+/dataStores/[^/]+/servingConfigs/[^/]+/?$}, false]
]
)
.with_bindings(
uri_method: :post,
uri_template: "/v1/{serving_config}:searchLite",
body: "*",
matches: [
["serving_config", %r{^projects/[^/]+/locations/[^/]+/collections/[^/]+/dataStores/[^/]+/servingConfigs/[^/]+/?$}, false]
]
)
.with_bindings(
uri_method: :post,
uri_template: "/v1/{serving_config}:searchLite",
body: "*",
matches: [
["serving_config", %r{^projects/[^/]+/locations/[^/]+/collections/[^/]+/engines/[^/]+/servingConfigs/[^/]+/?$}, false]
]
)
transcoder.transcode request_pb
end
end
end
end
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f405b9a

Please sign in to comment.