Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
Method: documents.searchDocumentChunks
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
HTTP 要求
GET https://developerknowledge.googleapis.com/v1alpha/documents:searchDocumentChunks
這個網址使用 gRPC 轉碼語法。
查詢參數
| 參數 |
query |
string
必填。提供使用者提供的原始查詢字串,例如「如何建立 Cloud Storage bucket?」。
|
pageSize |
integer
(選用步驟) 指定要傳回的結果數上限。服務傳回的產品數量可能會少於這個值。 如未指定,最多將傳回 5 個結果。 許可的最大值為 100;超出的數值將一律指定為 100。
|
pageToken |
string
(選用步驟) 包含接收自前一個 documents.searchDocumentChunks 呼叫的網頁權杖。提供此項目即可擷取後續網頁。
|
filter |
string
(選用步驟) 對搜尋結果套用嚴格篩選器。運算式支援 https://google.aip.dev/160 中所述語法的子集。 documents.searchDocumentChunks 會傳回 DocumentChunk,但篩選器會套用至 DocumentChunk.document 欄位。
支援篩選的欄位:
contentLengthBytes (INTEGER):Document.content 欄位的長度 (以位元組為單位)。
dataSource (STRING):文件來源,例如 docs.cloud.google.com。如要查看語料庫中的完整資料來源清單,請前往 https://developers.google.com/knowledge/reference/corpus-reference。
updateTime (TIMESTAMP):文件上次有意義更新的時間戳記。有意義的更新是指變更文件的 Markdown 內容或中繼資料。
uri (STRING):文件 URI,例如 https://docs.cloud.google.com/bigquery/docs/tables。
INTEGER 欄位支援 =、<、<=、> 和 >= 運算子。 STRING 欄位支援 = (等於) 和 != (不等於) 運算子,可完全比對整個字串。系統不支援部分比對、前置字元比對和規則運算式比對。 TIMESTAMP 欄位支援 =、<、<=、> 和 >= 運算子。時間戳記必須採用 RFC-3339 格式,例如 "2025-01-01T00:00:00Z"。 您可以使用 AND、OR 和 NOT (或 -) 邏輯運算子合併運算式。OR 的優先順序高於 AND。使用括號明確分組,以決定優先順序。 範例:
- 依
Document.content_length_bytes篩選:contentLengthBytes < 50000
dataSource = "docs.cloud.google.com" OR dataSource =
"firebase.google.com"
dataSource != "firebase.google.com"
updateTime < "2024-01-01T00:00:00Z"
updateTime >= "2025-01-22T00:00:00Z" AND (dataSource =
"developer.chrome.com" OR dataSource = "web.dev")
uri = "https://docs.cloud.google.com/release-notes"
filter 字串不得超過 500 個字元,否則會導致 INVALID_ARGUMENT 錯誤。
|
回應主體
| JSON 表示法 |
{
"results": [
{
object (DocumentChunk)
}
],
"nextPageToken": string
} |
| 欄位 |
results[] |
object (DocumentChunk)
包含指定查詢的搜尋結果。這份清單中的每個 DocumentChunk 都包含與搜尋查詢相關的內容摘要。使用每個結果的 DocumentChunk.parent 欄位搭配 DeveloperKnowledge.GetDocument 或 DeveloperKnowledge.BatchGetDocuments,即可擷取完整的文件內容。
|
nextPageToken |
string
(選用步驟) 提供可做為 pageToken 傳送的權杖,用於擷取後續網頁。如果省略這個欄位,就不會有後續頁面。
|
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/devprofiles.full_control
https://www.googleapis.com/auth/cloud-platform
詳情請參閱OAuth 2.0 Overview。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2026-07-10 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2026-07-10 (世界標準時間)。"],[],[]]