Skip to content

Commit

Permalink
Merge branch 'main' into renovate/pin-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pattishin authored Oct 6, 2023
2 parents 9a3e3b4 + 4549a3e commit 87fc22f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
19 changes: 13 additions & 6 deletions discoveryengine/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function main(
projectId,
location,
collectionId,
searchEngineId,
dataStoreId,
servingConfigId,
searchQuery
) {
Expand All @@ -28,26 +28,33 @@ async function main(
* TODO(developer): Uncomment these variables before running the sample.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'YOUR_LOCATION'; // Options: 'global'
// const location = 'YOUR_LOCATION'; // Options: 'global', 'us', 'eu'
// const collectionId = 'default_collection'; // Options: 'default_collection'
// const searchEngineId = 'YOUR_SEARCH_ENGINE_ID' // Create in Cloud Console
// const dataStoreId = 'YOUR_DATA_STORE_ID' // Create in Cloud Console
// const servingConfigId = 'default_config'; // Options: 'default_config'
// const searchQuery = 'Google';

const {SearchServiceClient} = require('@google-cloud/discoveryengine').v1beta;

// For more information, refer to:
// https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_store
const apiEndpoint =
location === 'global'
? 'discoveryengine.googleapis.com'
: `${location}-discoveryengine.googleapis.com`;

// Instantiates a client
const client = new SearchServiceClient();
const client = new SearchServiceClient({apiEndpoint: apiEndpoint});

async function search() {
// The full resource name of the search engine serving configuration.
// Example: projects/{projectId}/locations/{location}/collections/{collectionId}/dataStores/{searchEngineId}/servingConfigs/{servingConfigId}
// Example: projects/{projectId}/locations/{location}/collections/{collectionId}/dataStores/{dataStoreId}/servingConfigs/{servingConfigId}
// You must create a search engine in the Cloud Console first.
const name = client.projectLocationCollectionDataStoreServingConfigPath(
projectId,
location,
collectionId,
searchEngineId,
dataStoreId,
servingConfigId
);

Expand Down
4 changes: 2 additions & 2 deletions discoveryengine/test/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cwd = path.join(__dirname, '..');
const LOCATION = 'global';
const SEARCH_ENGINE_ID = 'cloud-google-com_1684250565013';
const DATA_STORE_ID = 'cloud-google-com_1684250565013';
const COLLECTION_ID = 'default_collection';
const SERVING_CONFIG_ID = 'default_config';
const SEARCH_QUERY = 'Google';
Expand All @@ -38,7 +38,7 @@ describe('Search', () => {
});
it('should run genappbuilder search (v1beta)', async () => {
const stdout = execSync(
`node ./search.js ${projectId} ${LOCATION} ${COLLECTION_ID} ${SEARCH_ENGINE_ID} ${SERVING_CONFIG_ID} ${SEARCH_QUERY}`,
`node ./search.js ${projectId} ${LOCATION} ${COLLECTION_ID} ${DATA_STORE_ID} ${SERVING_CONFIG_ID} ${SEARCH_QUERY}`,
{
cwd,
}
Expand Down

0 comments on commit 87fc22f

Please sign in to comment.