File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -397,6 +397,30 @@ Refer to the :manual:`Unique Indexes page </core/index-unique>` in the MongoDB s
397397
398398.. driver-content-end
399399
400+ Clustered Indexes
401+ ~~~~~~~~~~~~~~~~~
402+
403+ **Clustered indexes** instruct a collection to store documents ordered
404+ by a key value. To create a clustered index, specify the clustered index
405+ option with the ``_id`` field as the key and the unique field as
406+ ``true`` when you create your collection.
407+
408+ The following example creates a clustered index on the ``_id`` field in
409+ the ``vendors`` collection:
410+
411+ .. code-block:: java
412+
413+ MongoDatabase database = mongoClient.getDatabase("tea");
414+ ClusteredIndexOptions clusteredIndexOptions = new ClusteredIndexOptions(new Document("_id", 1), true);
415+ CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions().clusteredIndexOptions(clusteredIndexOptions);
416+
417+ database.createCollection("vendors", createCollectionOptions);
418+
419+ See the MongoDB server manual sections for more information:
420+
421+ - :ref:`Clustered Indexes <db.createCollection.clusteredIndex>`
422+ - :ref:`Clustered Collections <clustered-collections>`
423+
400424Remove an Index
401425---------------
402426
You can’t perform that action at this time.
0 commit comments