curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:search" \
-d '{
"servingConfig": "projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search",
"query": "When was Verily founded and what is its mission?",
"relevanceScoreSpec": {
"returnRelevanceScore": true
}
}'
{
"results": [
{
"id": "f1b0d98bd2a078a6dfb4f809c3028565",
"document": {
"name": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f1b0d98bd2a078a6dfb4f809c3028565",
"id": "f1b0d98bd2a078a6dfb4f809c3028565",
"derivedStructData": {
"link": "gs://cloud-samples-data/gen-app-builder/search/alphabet-investor-pdfs/2019_alphabet_annual_report.pdf",
"extractive_answers": [
{
"pageNumber": "70",
"content": "VERILY Verily is a life science and healthcare company with a mission to make the world's health data useful so that people enjoy healthier lives. In December 2018, Verily received $900 million in cash from a $1.0 billion investment round. The remaining $100 million was received in the first quarter of 2019."
}
],
"title": "2019_alphabet_annual_report"
}
},
"modelScores": {
"relevance_score": {
"values": [
0.7
]
}
}
},
{
"id": "0371b29bfa18ac43896b86a7b63d00b0",
"document": {
"name": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/0371b29bfa18ac43896b86a7b63d00b0",
"id": "0371b29bfa18ac43896b86a7b63d00b0",
"derivedStructData": {
"link": "gs://cloud-samples-data/gen-app-builder/search/alphabet-investor-pdfs/20190429_alphabet_10Q.pdf",
"title": "GOOG 10-Q Q1 2019",
"extractive_answers": [
{
"content": "Verily Verily is a life science company with a mission to make the world's health data useful so that people enjoy healthier lives. In December 2018, Verily received $900 million in cash from a $1.0 billion investment round. The remaining $100 million was received in the first quarter of 2019.",
"pageNumber": "21"
}
]
}
},
"modelScores": {
"relevance_score": {
"values": [
0.5
]
}
}
},
...
{
"id": "e6bbd0d82dc2a2fc7ccf1bd82ac6334f",
"document": {
"name": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/e6bbd0d82dc2a2fc7ccf1bd82ac6334f",
"id": "e6bbd0d82dc2a2fc7ccf1bd82ac6334f",
"derivedStructData": {
"title": "2021_Q1_Earnings_Transcript",
"link": "gs://cloud-samples-data/gen-app-builder/search/alphabet-investor-pdfs/2021_Q1_Earnings_Transcript.pdf",
"extractive_answers": [
{
"pageNumber": "2",
"content": "Our strength in AI and ML is also helping Financial Services customers improve efficiency of payments, reduce fraud and risk, and deliver faster payment solutions."
}
]
}
},
"modelScores": {
"relevance_score": {
"values": [
0
]
}
}
}
],
"totalSize": 76,
"attributionToken": "8QHw8AoLCIW4_b0GELHd3lgSJDY3YmU1ZGMwLTAwMDAtMmM1OC04NzcyLTc0NzQ0NjNiOGMyNSIHR0VORVJJQyqcAcb77TDHy_MX8tntMI6-nRWK4uQwwvCeFYX77TDvifIwq8SKLauR3zCq-LMt0IrIMNSynRWc1rctv_7kML7l3zDZveQwkPeyMMP77TD12e0wpd_hMIfi5DCRv9owgvvtMJWSxTCOkckwu-XfMK7Eii3sifIwqJHfMKjf4TCt-LMtlL_aMJ_Wty23t4wto4CXIs2KyDDcveQwwv7kMDABShIweDU3MGFkYWI4MzQ4NmY0MGE",
"nextPageToken": "UjMjhjYzYDN0cDN30iM3cDOtgTNjJTLwADMw0iZiRWNlJ2N2QiGBUd0gWLEG4bjhWICMIBM1IgC",
"summary": {},
"queryExpansionInfo": {}
}
搜尋摘要功能因模型而異
如果您為查詢產生搜尋摘要,可能會發現主控台結果和 API 結果的摘要有所不同。如果看到這則訊息,可能是因為控制台使用的 LLM 模型與 API 不同。本頁的 curl 和程式碼範例使用穩定版 LLM 模型。