-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add lite search API to allow public website search with API key (…
…#7765) * try comparing from origin * feat: add lite search API to allow public website search with API key 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 PiperOrigin-RevId: 689588291 Source-Link: googleapis/googleapis@537fd48 Source-Link: googleapis/googleapis-gen@186fcc4 Copy-Tag: eyJwIjoiRGlzY292ZXJ5RW5naW5lLy5Pd2xCb3QueWFtbCIsImgiOiIxODZmY2M0ZTIwYTJjMDZiYjUxNGEyZmY4ZDk0ZWI3ZjdkNjQ3MGMzIn0= Co-authored-by: Brent Shaffer <[email protected]> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5271d4e
commit 0bd701e
Showing
14 changed files
with
351 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
98 changes: 98 additions & 0 deletions
98
DiscoveryEngine/samples/V1/SearchServiceClient/search_lite.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START discoveryengine_v1_generated_SearchService_SearchLite_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\PagedListResponse; | ||
use Google\Cloud\DiscoveryEngine\V1\Client\SearchServiceClient; | ||
use Google\Cloud\DiscoveryEngine\V1\SearchRequest; | ||
use Google\Cloud\DiscoveryEngine\V1\SearchResponse\SearchResult; | ||
|
||
/** | ||
* Performs a search. Similar to the | ||
* [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] | ||
* method, but a lite version that allows API key for authentication, where | ||
* OAuth and IAM checks are not required. | ||
* | ||
* Only public website search is supported by this method. If data stores and | ||
* engines not associated with public website search are specified, a | ||
* `FAILED_PRECONDITION` error is returned. | ||
* | ||
* This method can be used for easy onboarding without having to implement an | ||
* authentication backend. However, it is strongly recommended to use | ||
* [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] | ||
* instead with required OAuth and IAM checks to provide better data security. | ||
* | ||
* @param string $formattedServingConfig The resource name of the Search serving config, such as | ||
* `projects/*/locations/global/collections/default_collection/engines/*/servingConfigs/default_serving_config`, | ||
* or | ||
* `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. | ||
* This field is used to identify the serving configuration name, set | ||
* of models used to make the search. Please see | ||
* {@see SearchServiceClient::servingConfigName()} for help formatting this field. | ||
*/ | ||
function search_lite_sample(string $formattedServingConfig): void | ||
{ | ||
// Create a client. | ||
$searchServiceClient = new SearchServiceClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new SearchRequest()) | ||
->setServingConfig($formattedServingConfig); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var PagedListResponse $response */ | ||
$response = $searchServiceClient->searchLite($request); | ||
|
||
/** @var SearchResult $element */ | ||
foreach ($response as $element) { | ||
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); | ||
} | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedServingConfig = SearchServiceClient::servingConfigName( | ||
'[PROJECT]', | ||
'[LOCATION]', | ||
'[DATA_STORE]', | ||
'[SERVING_CONFIG]' | ||
); | ||
|
||
search_lite_sample($formattedServingConfig); | ||
} | ||
// [END discoveryengine_v1_generated_SearchService_SearchLite_sync] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
DiscoveryEngine/src/V1/BatchGetDocumentsMetadataResponse/DocumentMetadata/MatcherValue.php
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,11 @@ | |
"methods": [ | ||
"search" | ||
] | ||
}, | ||
"SearchLite": { | ||
"methods": [ | ||
"searchLite" | ||
] | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.