From 16e055cdb08835d0aa48dd418cfbd5bfc334b094 Mon Sep 17 00:00:00 2001 From: Michael Morisi Date: Mon, 22 Jul 2024 09:05:46 -0400 Subject: [PATCH] Address AS feedback --- source/indexes/single-field-index.txt | 23 +++++++++++++++++++++-- source/work-with-indexes.txt | 17 +++++++---------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/source/indexes/single-field-index.txt b/source/indexes/single-field-index.txt index 83712fe..cf777f9 100644 --- a/source/indexes/single-field-index.txt +++ b/source/indexes/single-field-index.txt @@ -25,6 +25,11 @@ single field within a collection's documents. They improve single field query an performance, and support :manual:`TTL Indexes ` that automatically remove documents from a collection after a certain amount of time or at a specific clock time. +When creating a single-field index, you must specify the following: + +- The field on which to create the index +- The sort order for the indexed values (ascending or descending) + .. note:: The ``_id_`` index is an example of a single-field index. This index is automatically @@ -38,7 +43,7 @@ database from the :atlas:`Atlas sample datasets `. To learn how to free MongoDB Atlas cluster and load the sample datasets, see the :atlas:`Get Started with Atlas ` guide. -The documents in this collection are modeled by the following {+language+} data class: +The following {+language+} data class models the documents in this collection: .. literalinclude:: /includes/indexes/indexes.kt :start-after: start-movie-class @@ -74,4 +79,18 @@ The following is an example of a query that is covered by the index created in t Movie(id=573a1398f29313caabceb515, title=Batman, ...) -To learn more, see :manual:`Single Field Indexes ` in the {+mdb-server+} manual. +Additional Information +---------------------- + +To learn more about single-field indexes, see :manual:`Single Field Indexes ` +in the {+mdb-server+} manual. + +API Documentation +~~~~~~~~~~~~~~~~~ + +To learn more about any of the methods or types discussed in this +guide, see the following API Documentation: + +- `find() <{+api+}/mongodb-driver-kotlin-sync/com.mongodb.kotlin.client/-mongo-collection/find.html>`__ +- `filter() <{+api+}/mongodb-driver-kotlin-sync/com.mongodb.kotlin.client/-find-iterable/filter.html>`__ +- `sort() <{+api+}/mongodb-driver-kotlin-sync/com.mongodb.kotlin.client/-find-iterable/sort.html/>`__ \ No newline at end of file diff --git a/source/work-with-indexes.txt b/source/work-with-indexes.txt index d230318..053b770 100644 --- a/source/work-with-indexes.txt +++ b/source/work-with-indexes.txt @@ -41,13 +41,11 @@ your application's queries and operations that return sorted results. Each index that you add consumes disk space and memory when active, so we recommend that you track index memory and disk usage for capacity planning. In addition, when a write operation updates an indexed field, MongoDB updates the related -index. +index, which can negatively impact performance for write operations. -Because MongoDB supports dynamic schemas, applications can query against fields -whose names are not known in advance or are arbitrary. MongoDB 4.2 introduced -:manual:`wildcard indexes ` to help support these -queries. Wildcard indexes are not designed to replace workload-based index -planning. +You can use :manual:`wildcard indexes ` in your MongoDB application +to query against fields whose names are not known in advance or are arbitrary. Wildcard +indexes are not designed to replace workload-based index planning. For more information about designing your data model and choosing indexes appropriate for your application, see the :manual:`Data Modeling and Indexes ` guide @@ -64,7 +62,7 @@ free MongoDB Atlas cluster and load the sample datasets, see the Create an Index --------------- -MongoDB supports several different index types to support querying your data. +MongoDB supports several different index types to help query your data. The following pages describe the most common index types and provide sample code for creating each index type. @@ -79,7 +77,7 @@ Remove an Index You can remove any unused index except the default unique index on the ``_id`` field. -The following sections show how to remove a single index or to remove all +The following sections show how to remove a single index or how to remove all indexes in a collection. Delete a Single Index @@ -105,8 +103,7 @@ collection: Delete All Indexes ~~~~~~~~~~~~~~~~~~ -Starting with MongoDB 4.2, you can drop all indexes by calling the -``dropIndexes()`` method on your collection: +You can drop all indexes by calling the ``dropIndexes()`` method on your collection: .. literalinclude:: /includes/indexes/indexes.kt :language: kotlin