在 Google 的開發人員說明文件中搜尋開發人員知識。根據使用者的查詢傳回 DocumentChunk。同一個 Document 可能會有多個區塊。如要擷取完整文件,請搭配 SearchDocumentChunksResponse.results 中傳回的 DocumentChunk.parent 使用 DeveloperKnowledge.GetDocument 或 DeveloperKnowledge.BatchGetDocuments。
HTTP 要求
GET https://developerknowledge.googleapis.com/v1alpha/documents:searchDocumentChunks
這個網址使用 gRPC 轉碼語法。
查詢參數
| 參數 | |
|---|---|
query |
必填。提供使用者提供的原始查詢字串,例如「如何建立 Cloud Storage bucket?」。 |
pageSize |
(選用步驟) 指定要傳回的結果數上限。服務傳回的產品數量可能會少於這個值。 如未指定,最多將傳回 5 個結果。 最大值為 20;超過 20 的值會導致 INVALID_ARGUMENT 錯誤。 |
pageToken |
(選用步驟) 包含接收自前一個 |
要求主體
要求主體必須為空白。
回應主體
DeveloperKnowledge.SearchDocumentChunks 的回應訊息。
如果成功,回應主體會含有以下結構的資料:
| JSON 表示法 |
|---|
{
"results": [
{
object ( |
| 欄位 | |
|---|---|
results[] |
包含指定查詢的搜尋結果。這份清單中的每個 |
nextPageToken |
(選用步驟) 提供可做為 |
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/devprofiles.full_controlhttps://www.googleapis.com/auth/cloud-platform
詳情請參閱OAuth 2.0 Overview。
DocumentChunk
DocumentChunk 代表 DeveloperKnowledge 語料庫中 Document 的一小段內容。如要擷取整份文件內容,請將 parent 傳遞至 DeveloperKnowledge.GetDocument 或 DeveloperKnowledge.BatchGetDocuments。
| JSON 表示法 |
|---|
{ "parent": string, "id": string, "content": string } |
| 欄位 | |
|---|---|
parent |
僅供輸出。包含這個區塊所屬文件的資源名稱。格式: |
id |
僅供輸出。指定文件內這個區塊的 ID。區塊 ID 在文件中不得重複,但不同文件可以重複使用。區塊 ID 不穩定,可能會隨著時間而改變。 |
content |
僅供輸出。包含文件區塊的內容。 |