Method: projects.databases.documents.partitionQuery

傳回可用來平行執行查詢的分區遊標,將查詢分區。傳回的分區遊標是分割點,可由 document.runQuery 使用,做為查詢結果的起點/終點。

HTTP 要求

POST https://firestore.googleapis.com/v1beta1/{parent=projects/*/databases/*/documents}:partitionQuery

這個網址使用 gRPC 轉碼語法。

路徑參數

參數
parent

string

必要欄位。父項資源名稱。請採用下列格式:projects/{projectId}/databases/{databaseId}/documents。系統不支援文件資源名稱,只能指定資料庫資源名稱。

要求主體

要求主體的資料會採用以下結構:

JSON 表示法
{
  "partitionCount": string,
  "pageToken": string,
  "pageSize": integer,

  // Union field query_type can be only one of the following:
  "structuredQuery": {
    object (StructuredQuery)
  }
  // End of list of possible types for union field query_type.

  // Union field consistency_selector can be only one of the following:
  "readTime": string
  // End of list of possible types for union field consistency_selector.
}
欄位
partitionCount

string (int64 format)

所需的分區點數量上限。分區可能會在結果的多個頁面中傳回。數字必須為正數。實際傳回的分區數量可能較少。

舉例來說,這個項目可以設為少於平行查詢數量的一個,或在執行資料管道工作時,設為少於 1 個,低於可用的工作站或運算執行個體數量。

pageToken

string

先前呼叫 document.partitionQuery 傳回的 nextPageToken 值,可能會用來取得其他結果。提醒你,我們無法保證各結果組合之間的排序。因此,使用多組結果時,必須合併不同的結果集。

舉例來說,使用 pageToken 的後續兩次呼叫可能會傳回:

  • 遊標 B,遊標 M,遊標 Q
  • 遊標 A,遊標 U,遊標 W

如要針對提供至 document.partitionQuery 的查詢結果,取得完整的結果集,請合併結果集:遊標 A、遊標 B、遊標 M、遊標 Q、遊標 U、遊標 W

pageSize

integer

這項呼叫中要傳回的分區數量上限 (取決於 partitionCount)。

舉例來說,如果 partitionCount = 10 且 pageSize = 8,第一次呼叫 document.partitionQuery 會傳回最多 8 個分區,如果還有更多結果,則會傳回 nextPageToken。第二次呼叫 document.partitionQuery 最多會傳回 2 個分區,完成 partitionCount 中指定的共 10 個。

聯集欄位 query_type。要分區的查詢。query_type 只能是下列其中一項:
structuredQuery

object (StructuredQuery)

結構化查詢。查詢必須指定所有子系的集合,並依名稱遞增排序。不支援其他篩選器、排序依據、限制、偏移和開始/結束遊標。

聯集欄位 consistency_selector。這項要求的一致性模式。如果未設定,則預設為同步一致性。consistency_selector 只能是下列其中一項:
readTime

string (Timestamp format)

這個外掛程式能在指定時間讀取文件。

這個值必須是過去 1 小時內的微秒精確度,如果已啟用「時間點復原」功能,則可以是過去 7 天內的整分鐘時間戳記。

採用 RFC3339 世界標準時間「Zulu」格式的時間戳記,採用奈秒解析度和最多九個小數位數。範例:"2014-10-02T15:01:23Z""2014-10-02T15:01:23.045123456Z"

回應主體

Firestore.PartitionQuery 的回應。

如果成功,回應主體即會包含具有以下結構的資料:

JSON 表示法
{
  "partitions": [
    {
      object (Cursor)
    }
  ],
  "nextPageToken": string
}
欄位
partitions[]

object (Cursor)

分區結果。每個分區都是一個分割點,可由 document.runQuery 做為查詢結果的起點或終點。您必須使用針對此 document.partitionQuery 要求提供的相同查詢提交 document.runQuery 要求。分區遊標的順序與提供給 document.partitionQuery 的查詢結果順序相同。

舉例來說,如果 document.partitionQuery 要求傳回分區遊標 A 和 B,則執行以下三個查詢就會傳回原始查詢的完整結果集:

  • 查詢,endAt A
  • 查詢, startAt A, endAt B
  • 查詢,startAt B

空白結果可能表示查詢的結果太少,無法分區,或是查詢尚未支援分區。

nextPageToken

string

網頁憑證,可用來要求一組額外結果,最多可在 document.partitionQuery 要求中 partitionCount 指定的數字內。如果留空,表示沒有其他結果。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

詳情請參閱驗證總覽