My mongodb is v4.2.0,
when use the UI function to create indexes,it doesn't work.
I must use the shell command
>db.collection.createIndex(keys, options)
to create a index.
But when I use the UI function "Add Index" to edit my index,it is removed!!!!
I just ran into that too and spent some time until I figured it out, so I thought I'd share my findings, just in case someone wants to check out why it does not work at all right now and implement index creation for 4.2:
1. Unique Indexes
Support for dropDups on createIndex for unique indexes was removed in MongoDB 3.0
Source: https://docs.mongodb.com/manual/release-notes/3.0-compatibility/#remove-dropdups-option
If you already have duplicates in your collection and try to create a unique index, the index will not be created. This is expected behavior: See https://docs.mongodb.com/manual/core/index-unique/index.html (Behavior)
Robo3T should output this as an error.
So as I understand it, you have to remove duplicates by yourself now before creating a unique index.
And while we are at it:
2. Create in in Background
Deprecated in MongoDB 4.2 - You don't need it anymore as MongoDB now determines by itself how to best create indexes. https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/
As @DancyLon stated, right now Robo3T doesn't create any indexes on MongoDB 4.2, in fact it removes already created indexes when you try to edit them. As this can be quite harmful to the overall performance of your db, this should be fixed (or index creation removed alltogether) urgently. Until then: be aware.
@DancyLon , @rx2347 , thanks a lot for your inputs and sorry for this inconvenience. Robo 1.3 does not support Mongodb 4.2. (https://github.com/Studio3T/robomongo#supported-platforms)
Also, another problem here, which is probably the root cause of your dropped index problems, is that MongoDB does not have "edit index" feature.
From MongoDB docs:
To modify an existing index, you need to drop and recreate the index.
Source: https://docs.mongodb.com/manual/tutorial/manage-indexes/#modify-an-index
It means that if the "create index" fails, you end up with a dropped index. It might be possible for Robo to try to re-create the old "dropped" index if create index fails. We will consider this option.
We have already started to work on this issue, seems that we have already found the core problems. The fix is planned to be included in new Robo version 1.4.
Mongodb 4.2 is also planned to be supported in new Robo version 1.4. Hope to release in 1-2 months.
Hi all, we have some fixes related to this problem.
I hope Robo 3T 1.4 will fix it -> Robo 3T 1.4
Please let us know.
It works fine, now: Robo 3T 1.4.1 (Build 122dbd9) and MongoDB 4.2
Most helpful comment
I just ran into that too and spent some time until I figured it out, so I thought I'd share my findings, just in case someone wants to check out why it does not work at all right now and implement index creation for 4.2:
1. Unique Indexes
Support for dropDups on createIndex for unique indexes was removed in MongoDB 3.0
Source: https://docs.mongodb.com/manual/release-notes/3.0-compatibility/#remove-dropdups-option
If you already have duplicates in your collection and try to create a unique index, the index will not be created. This is expected behavior: See https://docs.mongodb.com/manual/core/index-unique/index.html (Behavior)
Robo3T should output this as an error.
So as I understand it, you have to remove duplicates by yourself now before creating a unique index.
And while we are at it:
2. Create in in Background
Deprecated in MongoDB 4.2 - You don't need it anymore as MongoDB now determines by itself how to best create indexes. https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/
As @DancyLon stated, right now Robo3T doesn't create any indexes on MongoDB 4.2, in fact it removes already created indexes when you try to edit them. As this can be quite harmful to the overall performance of your db, this should be fixed (or index creation removed alltogether) urgently. Until then: be aware.