-
Notifications
You must be signed in to change notification settings - Fork 1.7k
DOCS-654 new 2.0 index format #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
======================= | ||
Build Old Style Indexes | ||
======================= | ||
|
||
.. default-domain:: mongodb | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should have a warning or note that says you don't ever actually want to do this unless you need to have indexes that are compatible with versions of mongod before 1.8.2? |
||
.. important:: | ||
|
||
Use this procedure *only* if you must have indexes that are compatible | ||
with a version of MongoDB earlier than 2.0. | ||
|
||
MongoDB version 2.0 introduced the ``{v:1}`` index format. MongoDB | ||
versions 2.0 and later support both the ``{v:1}`` format and the | ||
earlier ``{v:0}`` format. | ||
|
||
MongoDB versions prior to 1.8.2, however, support only the ``{v:0}`` | ||
format. If you need to roll back MongoDB to a version prior to 2.0, you | ||
must *drop* and *re-create* your indexes. | ||
|
||
You do so using the :method:`dropIndexes() | ||
<db.collection.dropIndexes()>` and :method:`ensureIndex() | ||
<db.collection.ensureIndex()>` methods. You *cannot* simply reindex the | ||
collection. If you simply reindex, the ``v`` fields in your indexes | ||
would still hold values of ``1``, even though the indexes would now use | ||
the ``{v:0}`` format. If you were to upgrade again to version 2.0 or | ||
later, your indexes would not work. | ||
|
||
.. example:: | ||
|
||
Suppose you rolled back from MongoDB 2.0 to MongoDB 1.8, and suppose | ||
you had the following index on the ``items`` collection: | ||
|
||
.. code-block:: javascript | ||
|
||
{ "v" : 1, "key" : { "name" : 1 }, "ns" : "mydb.items", "name" : "name_1" } | ||
|
||
The ``v`` field tells you the index is a ``{v:1}`` index, which | ||
is incompatible with version 1.8. | ||
|
||
To drop the index, issue the following command: | ||
|
||
.. code-block:: javascript | ||
|
||
db.items.dropIndex( { name : 1 } ) | ||
|
||
To recreate the index as a ``{v:0}`` index, issue the following | ||
command: | ||
|
||
.. code-block:: javascript | ||
|
||
db.foo.ensureIndex( { name : 1 } , { v : 0 } ) | ||
|
||
.. seealso:: :ref:`2.0-new-index-format`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we need to introduce the new index type before the notes on conversion.