Skip to content

Commit 8092b2a

Browse files
author
Bob Grabar
committed
DOCS-654 review edits
1 parent 48261b5 commit 8092b2a

File tree

3 files changed

+66
-65
lines changed

3 files changed

+66
-65
lines changed

source/release-notes/2.0.txt

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,6 @@ In addition, you may see reduced write throughput.
4242
:program:`mongod` instances; however, for best results, upgrade your
4343
deployments using the following procedures:
4444

45-
.. _2.0-convert-to-new-index-format:
46-
47-
Converting an Existing Index to the New Format
48-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49-
50-
To convert all indexes for a given collection to the
51-
:ref:`2.0 type <2.0-new-index-format>`, invoke the
52-
:doc:`compact </reference/command/compact>` command.
53-
54-
All operations that create a new index will result in a 2.0 index by
55-
default. For example:
56-
57-
- Reindexing results on an older-version index results in a 2.0 index.
58-
However, reindexing on a secondary does *not* work in versions prior
59-
to 2.0. Do not reindex on a secondary. For a workaround, see
60-
:issue:`SERVER-3866`.
61-
62-
- The :setting:`repair` database command converts indexes to a 2.0
63-
indexes.
64-
6545
.. _2.0-upgrade-standalone:
6646

6747
Upgrading a Standalone ``mongod``
@@ -163,10 +143,23 @@ type are realized only if you create a new index or re-index an old one.
163143
Dates are now signed, and the max index key size has increased slightly
164144
from 819 to 1024 bytes.
165145

166-
Once you create new indexes, downgrading to 1.8.x will require a
167-
re-index of any indexes created using 2.0.
146+
All operations that create a new index will result in a 2.0 index by
147+
default. For example:
148+
149+
- Reindexing results on an older-version index results in a 2.0 index.
150+
However, reindexing on a secondary does *not* work in versions prior
151+
to 2.0. Do not reindex on a secondary. For a workaround, see
152+
:issue:`SERVER-3866`.
168153

169-
.. seealso:: :ref:`2.0-convert-to-new-index-format`
154+
- The :setting:`repair` database command converts indexes to a 2.0
155+
indexes.
156+
157+
To convert all indexes for a given collection to the :ref:`2.0 type
158+
<2.0-new-index-format>`, invoke the :dbcommand:`compact` command.
159+
160+
Once you create new indexes, downgrading to 1.8.x will require a
161+
re-index of any indexes created using 2.0. See
162+
:doc:`/tutorial/roll-back-to-v18-index`.
170163

171164
Sharding Authentication
172165
~~~~~~~~~~~~~~~~~~~~~~~

source/tutorial.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Development Patterns
5555
tutorial/create-an-auto-incrementing-field
5656
tutorial/enforce-unique-keys-for-sharded-collections
5757
tutorial/aggregation-examples
58+
tutorial/roll-back-to-v18-index
5859

5960
.. index:: tutorials; application development
6061
.. index:: application tutorials
Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,53 @@
1-
================================
2-
Roll Back to a Version 1.8 Index
3-
================================
1+
=======================
2+
Build Old Style Indexes
3+
=======================
44

55
.. default-domain:: mongodb
66

7+
.. important::
78

8-
MongoDB version 2.0 and later supports the old index format. But old versions
9-
will not support the new format. If you need to roll back to an older
10-
version, the server will run, but queries and other operations involving
11-
the newer indexes will log and return an error. Thus, you will need to
12-
re-create any new index you would like to use on an old server.
13-
14-
Versions prior to 1.8.2, inclusive, are not aware of the index version
15-
field. If you rollback a ``{v:1}`` index to 1.8.2 and re-index it, its
16-
version will still be marked ``{v: 1}``, although it actual is now version ``{v:0}``.
17-
If you upgrade again to 2.0, this index will not work, even though it is
18-
marked as ``{v: 1}`` in ``system.indexes``. If you must roll back to a
19-
version prior to 1.8.2, you must delete the index then create it again
20-
(instead of simply re-indexing).
21-
22-
Building a {v:0} Index
23-
----------------------
24-
25-
You can still create a ``{v:0}`` index with MongoDB version 2.0 or later. To do so, add the
26-
option ``{v:0}`` in the index creation command. For example in the :program:`mongo`
27-
shell:
28-
29-
.. code-block:: javascript
30-
31-
// defaults to a v:1 index
32-
db.foo.ensureIndex({name:1})
33-
db.system.indexes.find()
34-
{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "mydb.foo", "name" : "_id_" }
35-
{ "v" : 1, "key" : { "name" : 1 }, "ns" : "mydb.foo", "name" : "name_1" }
36-
db.foo.dropIndex({name:1})
37-
{ "nIndexesWas" : 2, "ok" : 1 }
38-
39-
// create a v:0 index
40-
db.foo.ensureIndex({name:1},{v:0})
41-
db.system.indexes.find()
42-
{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "mydb.foo", "name" : "_id_" }
43-
44-
{ "v" : 0, "key" : { "name" : 1 }, "ns" : "mydb.foo", "name" : "name_1" }
45-
46-
.. seealso:: :ref:`2.0-new-index-format` and :ref:`2.0-convert-to-new-index-format`
9+
Use this procedure *only* if you must have indexes that are compatible
10+
with a version of MongoDB earlier than 2.0.
11+
12+
MongoDB version 2.0 introduced the ``{v:1}`` index format. MongoDB
13+
versions 2.0 and later support both the ``{v:1}`` format and the
14+
earlier ``{v:0}`` format.
15+
16+
MongoDB versions prior to 1.8.2, however, support only the ``{v:0}``
17+
format. If you need to roll back MongoDB to a version prior to 2.0, you
18+
must *drop* and *re-create* your indexes.
19+
20+
You do so using the :method:`dropIndexes()
21+
<db.collection.dropIndexes()>` and :method:`ensureIndex()
22+
<db.collection.ensureIndex()>` methods. You *cannot* simply reindex the
23+
collection. If you simply reindex, the ``v`` fields in your indexes
24+
would still hold values of ``1``, even though the indexes would now use
25+
the ``{v:0}`` format. If you were to upgrade again to version 2.0 or
26+
later, your indexes would not work.
27+
28+
.. example::
29+
30+
Suppose you rolled back from MongoDB 2.0 to MongoDB 1.8, and suppose
31+
you had the following index on the ``items`` collection:
32+
33+
.. code-block:: javascript
34+
35+
{ "v" : 1, "key" : { "name" : 1 }, "ns" : "mydb.items", "name" : "name_1" }
36+
37+
The ``v`` field tells you the index is a ``{v:1}`` index, which
38+
is incompatible with version 1.8.
39+
40+
To drop the index, issue the following command:
41+
42+
.. code-block:: javascript
43+
44+
db.items.dropIndex( { name : 1 } )
45+
46+
To recreate the index as a ``{v:0}`` index, issue the following
47+
command:
48+
49+
.. code-block:: javascript
50+
51+
db.foo.ensureIndex( { name : 1 } , { v : 0 } )
52+
53+
.. seealso:: :ref:`2.0-new-index-format`.

0 commit comments

Comments
 (0)