@@ -17,13 +17,16 @@ development release series.
1717This document covers the 3.1 development series as a work-in-progress.
1818Features are subject to change.
1919
20+
2021.. |version-dev| replace:: 3.1.6
2122
23+ .. |version-wt-default| replace:: 3.1.4 or greater
24+
2225WiredTiger as Default
2326---------------------
2427
25- Starting in 3.1.4, MongoDB uses the WiredTiger as the default
26- storage engine.
28+ Starting in 3.1.4, MongoDB uses the WiredTiger as the default storage
29+ engine.
2730
2831To specify the MMAPv1 storage engine, you must specify the storage
2932engine setting either:
@@ -42,6 +45,18 @@ engine setting either:
4245 storage:
4346 engine: mmapv1
4447
48+ .. note::
49+
50+ For existing deployments, if you do not specify the
51+ ``--storageEngine`` or the :setting:`storage.engine` setting,
52+ MongoDB |version-wt| can automatically determine the storage engine
53+ used to create the data files in the ``--dbpath`` or
54+ :setting:`storage.dbPath`.
55+
56+ If specifying ``--storageEngine`` or :setting:`storage.engine`,
57+ :program:`mongod` will not start if ``dbPath`` contains data files
58+ created by a storage engine other than the one specified.
59+
4560Partial Indexes
4661---------------
4762
@@ -91,10 +106,38 @@ condition using:
91106Restrictions
92107~~~~~~~~~~~~
93108
94- - To use the partial index, a query **must** contain the filter
95- expression as part of its query condition unless you use a partial
96- index that specifies only the existence check on the index keys; i.e.
97- implement the sparse index behavior using a partial index.
109+ - MongoDB will not use the partial index if the index results in an
110+ incomplete result set for the query or sort operation.
111+
112+ To use the partial index, a query **must** contain the filter
113+ expression (or a modified filter expression that specifies a subset
114+ of the filter expression) as part of its query condition
115+
116+ For example, given the following index:
117+
118+ .. code-block:: javascript
119+
120+ db.restaurants.createIndex(
121+ { cuisine: 1, name: 1 },
122+ { partialFilterExpression: { rating: { $gt: 5 } } }
123+ )
124+
125+ The following queries can use the index since the query predicates
126+ includes a modified filter expressions ``rating: 6`` and ``rating: {
127+ $gte: 8 }`` that are subsets of the filter expression ``ratings: {
128+ $gt: 5 }``:
129+
130+ .. code-block:: javascript
131+
132+ db.restaurants.find( { rating: 6 } )
133+ db.restaruants.find( { cuisine: "Italian", rating: { $gte: 8 } } )
134+
135+ However, the following queries cannot use the partial index:
136+
137+ .. code-block:: javascript
138+
139+ db.restaurants.find( { rating: { $lt: 8 } } )
140+ db.restaruants.find( { cuisine: "Italian" } )
98141
99142- In MongoDB, you cannot create multiple versions of an index that
100143 differ only in the options. As such, you cannot create multiple
@@ -106,6 +149,10 @@ Restrictions
106149- Earlier versions of MongoDB do not support partial indexes. If using
107150 sharded clusters or replica set, all nodes must be version |version-dev|.
108151
152+ - ``_id`` indexes cannot be partial indexes.
153+
154+ - Shard key indexes cannot be partial indexes.
155+
109156Comparison with the ``sparse`` Index
110157~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111158
@@ -209,14 +256,19 @@ Add Validation to a New Collection
209256``````````````````````````````````
210257
211258The following example creates a collection ``contact`` with a validator
212- that specifies that either the ``phone`` field must exist or the
213- ``email`` field must exist or the ``status`` field equals ``Unknown``.
259+ that specifies that either the ``phone`` field must be a string or the
260+ ``email`` field must match the regular expression or the ``status``
261+ field must be either ``Unknown`` or ``Incomplete``.
214262
215263.. code-block:: javascript
216264
217- db.createCollection( "contacts", {
265+ db.createCollection( "contacts", {
218266 validator: { $or:
219- [ { phone: { $exists: true } }, { email: { $exists: true } }, { status: "Unknown" } ]
267+ [
268+ { phone: { $type: "string" } },
269+ { email: { $regex: /@mongodb\.com$/ } },
270+ { status: { $in: [ "Unknown", "Incomplete" ] } }
271+ ]
220272 }
221273 } )
222274
@@ -890,9 +942,15 @@ Default Storage Engine
890942~~~~~~~~~~~~~~~~~~~~~~
891943
892944Starting in 3.1.4, MongoDB uses the WiredTiger as the default storage
893- engine. Previous versions used the MMAPv1 storage engine. As such, for
894- :program:`mongod` instances running MMAPv1,you must explicitly specify
895- the storage engine setting either:
945+ engine. Previous versions used the MMAPv1 as the storage engine.
946+
947+ For existing deployments, if you do not specify the ``--storageEngine``
948+ or the :setting:`storage.engine` setting, MongoDB automatically
949+ determines the storage engine used to create the data files in the
950+ ``--dbpath`` or :setting:`storage.dbPath`.
951+
952+ For new deployments, to use MMAPv1, you must explicitly specify the
953+ storage engine setting either:
896954
897955- On the command line with the ``--storageEngine`` option:
898956
0 commit comments