|
| 1 | +.. _clustered-collection: |
| 2 | + |
| 3 | +============================= |
| 4 | +Create a Clustered Collection |
| 5 | +============================= |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 1 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +:manual:`Clustered collections </core/clustered-collections/>` are collections |
| 16 | +with a clustered index. Clustered collections store documents ordered by :manual:`clustered index </reference/method/db.createCollection/#std-label-db.createCollection.clusteredIndex>` |
| 17 | +key value. You can use clustered collections when only one clustered index is |
| 18 | +necessary. |
| 19 | + |
| 20 | +Restrictions |
| 21 | +------------ |
| 22 | + |
| 23 | +Clustered collection limitations: |
| 24 | + |
| 25 | +- The clustered index key must be on the ``_id`` field. |
| 26 | + |
| 27 | +- Clustered collections may not be :manual:`capped collections <capped-collection>`. |
| 28 | + |
| 29 | +Steps |
| 30 | +----- |
| 31 | + |
| 32 | +.. procedure:: |
| 33 | + :style: connected |
| 34 | + |
| 35 | + .. step:: Open the :guilabel:`Create Collection` dialog box. |
| 36 | + |
| 37 | + Select a database and from the :guilabel:`Collections` screen, click the |
| 38 | + :guilabel:`Create Collection` button. |
| 39 | + |
| 40 | + You can also click the ``+`` next to the name of the database you select |
| 41 | + to open the :guilabel:`Create Collection` dialog box. |
| 42 | + |
| 43 | + .. figure:: /images/compass/new-collection.png |
| 44 | + :figwidth: 550px |
| 45 | + :alt: Create New Collection |
| 46 | + |
| 47 | + .. step:: Enter the collection name. |
| 48 | + |
| 49 | + .. step:: Select the type of collection you want to create. |
| 50 | + |
| 51 | + From the :guilabel:`Advanced Collection Options` drop-down, select |
| 52 | + :guilabel:`Clustered Collections`. |
| 53 | + |
| 54 | + .. step:: (Optional) Name your clustered index. |
| 55 | + |
| 56 | + You can enter a name for the clustered index or use the automatically |
| 57 | + generated name. |
| 58 | + |
| 59 | + .. step:: (Optional) Enter the number of seconds for the :guilabel:`expireAfterSeconds` field. |
| 60 | + |
| 61 | + The :guilabel:`expireAfterSeconds` field is a :manual:`TTL index </tutorial/expire-data/>` |
| 62 | + that enables automatic deletion of documents older than the specified |
| 63 | + number of seconds. The :guilabel:`expireAfterSeconds` field must be a positive, |
| 64 | + non-zero value. |
| 65 | + |
| 66 | + .. step:: Click :guilabel:`Create Collection` to create your new collection. |
| 67 | + |
| 68 | + In the :guilabel:`Collections` screen, your new collection is marked by a |
| 69 | + :guilabel:`Clustered` badge next to the collection name. |
| 70 | + |
| 71 | +Next Steps |
| 72 | +---------- |
| 73 | + |
| 74 | +- :ref:`Manage Documents <compass-documents>` |
| 75 | + |
| 76 | +- :ref:`Query Your Data<compass-query-bar>` |
| 77 | + |
| 78 | +- :ref:`Analyze Your Data Scheme <schema-tab>` |
0 commit comments