[[["わかりやすい","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"]],["最終更新日 2025-09-02 UTC。"],[],[],null,["\u003cbr /\u003e\n\n\n|--------------------------------------------------------|\n| *Relevant to Cloud Firestore Enterprise edition only.* |\n\n\u003cbr /\u003e\n\nUse the managed bulk delete service to delete data from your database. This\nfeature supports deletion against one or more collection groups.\n\nThis page describes how to delete documents in bulk using\nthe managed bulk delete service. The\nCloud Firestore with MongoDB compatibility managed bulk delete service is available through\nthe [`gcloud`](https://cloud.google.com/sdk/gcloud/)\ncommand-line tool and the Cloud Firestore [REST API](/docs/firestore/reference/rest/v1/projects.databases/bulkDeleteDocuments).\n| **Caution:** Bulk deleting data from Cloud Firestore with MongoDB compatibility incurs one delete operation per document deleted and some read operations based on a fraction of total documents read. However, these operations don't appear in the usage section of the console. Make sure that you understand this before issuing bulk deletes to avoid billed charges.\n\nBefore you begin\n\nBefore you can use the managed bulk delete service, you must complete the\nfollowing tasks:\n\n1. [Enable\n billing for your Google Cloud project.](https://cloud.google.com/billing/docs/how-to/modify-project) Only Google Cloud projects with billing enabled can use the bulk delete functionality.\n2. Make sure your account has the necessary permissions for\n Cloud Firestore with MongoDB compatibility. **If you are the project owner,\n your account has the required permissions.** Otherwise, the following\n roles grant the necessary permissions for bulk delete operations:\n\n - [Cloud Firestore with MongoDB compatibility roles:](/docs/firestore/enterprise/security/iam#predefined_roles) `Owner`, `Cloud Datastore Owner`, or `Cloud Datastore Bulk Admin` **Note:** These Datastore roles also grant permissions in Cloud Firestore.\n\nSet up `gcloud` for your project\n\nYou can initiate bulk delete operations through the Google Cloud console or\nthe `gcloud` command-line tool. To use `gcloud`, set up the command-line tool\nand connect to your project in one of the following ways:\n\n- Access `gcloud` from the Google Cloud console using [Cloud Shell](https://cloud.google.com/shell/).\n\n [Start Cloud Shell](https://console.cloud.google.com/?cloudshell=true)\n\n Make sure `gcloud` is configured for the correct project: \n\n gcloud config set project [PROJECT_ID]\n\n- [Install and initialize the Google Cloud SDK.](https://cloud.google.com/sdk/docs/quickstarts)\n\nBulk delete data\n\nA bulk delete operation first finds all applicable documents in your database and deletes them in batches. You may still query or read these documents while the results may vary based on the progress made. Bulk delete doesn't delete any documents added or modified after the operation starts.\n| **Note:** If you plan to delete all documents in the database, see the [database deletion feature](/docs/firestore/enterprise/create-databases#delete-database) instead.\n\nBulk delete specific collection groups \n\ngcloud\n\nTo bulk delete specific collection groups, use the\n[`--collection-ids`](https://cloud.google.com/sdk/gcloud/reference/beta/firestore/bulk-delete#FLAGS) flag. The operation deletes only\nthe collection groups with the given IDs.\n\n\u003cbr /\u003e\n\n```\ngcloud firestore bulk-delete \\\n--collection-ids=[COLLECTION_GROUP_ID_1_OR_KIND_1],[COLLECTION_GROUP_ID_2_OR_KIND_2],[SUBCOLLECTION_GROUP_ID_1_OR_KIND_3] \\\n--database=[DATABASE]\n```\n\nManage bulk delete operations\n\nAfter you start a bulk delete operation, Cloud Firestore with MongoDB compatibility assigns\nthe operation a unique name. You can use the operation name to delete,\ncancel, or check the status of the operation.\n\nOperation names are prefixed with `projects/[PROJECT_ID]/databases/[DATABASE_ID]/operations/`,\nfor example: \n\n```\nprojects/my-project/databases/(default)/operations/ASA1MTAwNDQxNAgadGx1YWZlZAcSeWx0aGdpbi1zYm9qLW5pbWRhEgopEg\n```\n\nHowever, you can leave out the prefix when specifying an operation name for\nthe `describe`, `cancel`, and `delete`commands.\n\nList all bulk delete operations \n\ngcloud\n\nUse the [`operations list`](https://cloud.google.com/sdk/gcloud/reference/firestore/operations/list) command to see all running and recently completed operations, including bulk delete operations: \n\n```\ngcloud firestore operations list\n```\n\nCheck operation status \n\ngcloud\n\nUse the [`operations describe`](https://cloud.google.com/sdk/gcloud/reference/firestore/operations/describe) command to show the status of a bulk delete operation. \n\n```\ngcloud firestore operations describe [OPERATION_NAME]\n```\n\nEstimate the completion time\n\nA request for the status of a long-running operation returns the metrics\n`workEstimated` and `workCompleted`. Each of these metrics is returned in both\nnumber of bytes and number of documents:\n\n- `workEstimated` shows the estimated total number of bytes and documents an\n operation will process. Cloud Firestore with MongoDB compatibility might omit this metric if it\n can't make an estimate.\n\n- `workCompleted` shows the number of bytes and documents deleted so far.\n After the operation completes, the value shows the total number of\n bytes and documents that were actually processed, which might be larger than the\n value of `workEstimated`.\n\nDivide `workCompleted` by `workEstimated` for a rough progress estimate. This\nestimate might be inaccurate, because it depends on delayed statistics\ncollection.\n\nCancel an operation \n\ngcloud\n\nUse the [`operations cancel`](https://cloud.google.com/sdk/gcloud/reference/firestore/operations/cancel) command to stop an operation in progress: \n\n```\ngcloud firestore operations cancel [OPERATION_NAME]\n```\n\nCancelling a running operation doesn't undo the operation. A cancelled bulk delete\noperation doesn't recover the deleted documents.\n\nDelete an operation\n\nUse the [`gcloud firestore operations delete`](https://cloud.google.com/sdk/gcloud/reference/firestore/operations/delete) command to remove\na completed operation from the list of recent operations. To cancel a running operation, use the earlier cancellation operation. \n\n```\ngcloud firestore operations delete [OPERATION_NAME]\n```\n\nBilling and pricing for bulk delete operations\n\nYou are required to enable billing for your Google Cloud project before you use\nthe managed bulk delete service.\n\nNote that Cloud Firestore with MongoDB compatibility charges on the actual work done. If the\noperation is cancelled or failed due to user error, you will be charged with\nprogress made. Cloud Firestore with MongoDB compatibility won't charge reads or deletes for the\ndocuments that are not eventually deleted, such as documents that\nare modified after the delete operation started. The cost will be attributed on\nthe day of operation completion.\n\nBulk delete operations doesn't trigger your\n[Google Cloud budget](https://cloud.google.com/billing/docs/how-to/budgets) alerts until after completion. Similarly,\nreads and deletes performed during a bulk delete operation are applied to\nyour free tier usage after the operation is complete. Bulk delete\noperations don't affect the usage shown in the usage section of the console.\n\nView bulk delete costs\n\nBulk delete operations apply the `goog-firestoremanaged:bulkdelete`\nlabel to billed operations. In the [Cloud Billing reports page](https://cloud.google.com/billing/docs/how-to/reports#getting_started),\nyou can use this label to view costs related to bulk delete operations."]]