Skip to content

Indexes

  • MongoDB

The index manager lists a collection’s indexes with their keys, type, options, size and usage. You can hide, unhide and drop indexes, and create every kind of index from a form that shows the exact createIndex command as you fill it in.

  • Choose Indexes from a collection’s menu in the explorer, or Manage indexes on its Indexes folder or on an index.
  • Choose Tools › Indexes in the collection view.

Views have no indexes, so they have no index manager.

Column Shows
Name The index name.
Keys The key pattern.
Type Badges such as TTL, partial, unique or sparse.
Options The index options.
Size The index size.
Usage Operations that used the index since its counter started (hover for the date).
Hidden Whether the index is hidden.

Hide makes the server keep an index but stop using it; Unhide brings it back. Drop… shows the dropIndex command and asks before it runs. The _id_ index has no buttons. Refresh reads the list again.

  1. Choose Create index….
  2. Pick a kind of index: Single field, Compound, TTL, Partial, Text, 2dsphere, Hashed or Wildcard. The kind fills in the form; you can change it after.
  3. Under Keys, enter each field and its type: 1 (ascending), -1 (descending), text, 2dsphere, 2d or hashed.
  4. Fill in the options you need (see below).
  5. Check the command under the form, for example db.getSiblingDB('catalog').products.createIndex({ addedAt: 1 }, { expireAfterSeconds: 3600 }).
  6. Choose Create index.
Option What it does
Name (optional) The index name. Without one, the server names it from the keys.
TTL seconds (expireAfterSeconds) Deletes documents this many seconds after the date in the key.
Default language (text) The language of a text index.
Unique Refuses duplicate keys.
Sparse Leaves out documents without the indexed field.
Hidden (built, not used) Builds the index hidden.
Partial filter expression Indexes only the documents that match, such as { status: { $eq: 'open' } }.
Collation Language rules for string comparison, such as { locale: 'en', strength: 2 }.
Wildcard projection ($**) Which fields a wildcard index covers.
Text weights The weight of each field in a text index.

Documents Querybara 0.1.1 · built frombc9f5aa