11

How can I use the Robo 3T GUI to create a simple index for one of the fields in a collection?

When I click on my collection, right click on the indexes folder and choose "add Index..." I see the next screen, what should I enter in the fields (mainly in the "Keys" field)?

Robo 3T Index Properties screenShot

Shai Rippel
  • 368
  • 1
  • 3
  • 12

1 Answers1

10

After some research and trial and error I found this is similar to the cli function db.collection.createIndex(keys, options)

About the Keys field: From the MongoDB documentation -

A document that contains the field and value pairs where the field is the index key and the value describes the type of index for that field. For an ascending index on a field, specify a value of 1; for descending index, specify a value of -1

Let's say our field to index name is "accountNumber", you can enter this to the "Keys" black box pictured above:

{
      "accountNumber" : 1
}

For the Name just enter something meaningfull like accountNumberIndex

*The "Unique" checkbox will only work if there aren't already duplicate entries

*Also the Drop Duplicates is deprecated in Mongo version 3

Shai Rippel
  • 368
  • 1
  • 3
  • 12
  • 2
    I'm using RoboMongo (1.0) and I could create an index using the UI or the `createIndex` function. If, however, I tried to use the UI and selected the checkbox **Unique** the index was not created (no error but not created). – PatS Apr 28 '19 at 23:23
  • Just trying to create a simple index on Robo3T, I get a pop up modal dialog with message "Please check json text". – JohnC May 28 '21 at 20:59