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.
Open the index manager
Section titled “Open the index manager”- 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.
The index list
Section titled “The index list”| 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.
Create an index
Section titled “Create an index”- Choose Create index….
- 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.
- Under Keys, enter each field and its type: 1 (ascending), -1 (descending), text, 2dsphere, 2d or hashed.
- Fill in the options you need (see below).
- Check the command under the form, for example
db.getSiblingDB('catalog').products.createIndex({ addedAt: 1 }, { expireAfterSeconds: 3600 }). - 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. |
Related
Section titled “Related”Documents Querybara 0.1.1 · built frombc9f5aa