Skip to content

Commit b5c144b

Browse files
authored
fix(discoveryengine): Update Search Sample to use Engine/App ID (GoogleCloudPlatform#11288)
1 parent 10a10d1 commit b5c144b

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

discoveryengine/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
google-cloud-discoveryengine==0.11.8
1+
google-cloud-discoveryengine==0.11.10
22
google-api-core==2.17.1

discoveryengine/search_sample.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121

2222
# TODO(developer): Uncomment these variables before running the sample.
2323
# project_id = "YOUR_PROJECT_ID"
24-
# location = "YOUR_LOCATION" # Values: "global", "us", "eu"
25-
# data_store_id = "YOUR_DATA_STORE_ID"
24+
# location = "YOUR_LOCATION" # Values: "global", "us", "eu"
25+
# engine_id = "YOUR_APP_ID"
2626
# search_query = "YOUR_SEARCH_QUERY"
2727

2828

2929
def search_sample(
3030
project_id: str,
3131
location: str,
32-
data_store_id: str,
32+
engine_id: str,
3333
search_query: str,
3434
) -> List[discoveryengine.SearchResponse]:
3535
# For more information, refer to:
@@ -43,14 +43,8 @@ def search_sample(
4343
# Create a client
4444
client = discoveryengine.SearchServiceClient(client_options=client_options)
4545

46-
# The full resource name of the search engine serving config
47-
# e.g. projects/{project_id}/locations/{location}/dataStores/{data_store_id}/servingConfigs/{serving_config_id}
48-
serving_config = client.serving_config_path(
49-
project=project_id,
50-
location=location,
51-
data_store=data_store_id,
52-
serving_config="default_config",
53-
)
46+
# The full resource name of the search app serving config
47+
serving_config = f"projects/{project_id}/locations/{location}/collections/default_collection/engines/{engine_id}/servingConfigs/default_config"
5448

5549
# Optional: Configuration options for search
5650
# Refer to the `ContentSearchSpec` reference for all supported fields:
@@ -72,7 +66,7 @@ def search_sample(
7266
preamble="YOUR_CUSTOM_PROMPT"
7367
),
7468
model_spec=discoveryengine.SearchRequest.ContentSearchSpec.SummarySpec.ModelSpec(
75-
version="stable", # Options: stable, preview
69+
version="stable",
7670
),
7771
),
7872
)

discoveryengine/search_sample_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
def test_search():
2525
location = "global"
26-
data_store_id = "test-search-engine_1689960780551"
26+
engine_id = "test-search-engine_1689960780551"
2727
response = search_sample.search_sample(
2828
project_id=project_id,
2929
location=location,
30-
data_store_id=data_store_id,
30+
engine_id=engine_id,
3131
search_query=search_query,
3232
)
3333

@@ -40,11 +40,11 @@ def test_search():
4040

4141
def test_search_eu_endpoint():
4242
location = "eu"
43-
data_store_id = "alphabet-earnings-reports-eu"
43+
engine_id = "test-search-engine-eu_1695154596291"
4444
response = search_sample.search_sample(
4545
project_id=project_id,
4646
location=location,
47-
data_store_id=data_store_id,
47+
engine_id=engine_id,
4848
search_query=search_query,
4949
)
5050

0 commit comments

Comments
 (0)