MongoDB Documentation, Release 3.0.4 Warning: MongoDB hashed indexes truncate floating point numbers to 64-bit integers before hashing. For example, a hashed index would store the same value for a field that held a value of 2.3 , 2.2 , and 2.9 . To prevent collisions, do not use a hashed index for floating point numbers that cannot be reliably converted to 64-bit integers (and then back to floating point). MongoDB hashed indexes do not support floating point values larger than 2$^{53}$. Create a hashed index using an operation that resembles the following: db.active.createIndex( { a: "hashed" } ) This operation creates a hashed index for the active collection on the a field. In addition to the numerous index types (page 486) MongoDB supports, indexes can also have various properties. The following documents detail the index properties that you can select when building an index. TTL indexes are special single-field indexes that MongoDB can use to automatically remove documents from a col- lection after a certain amount of time. Data expiration is useful for certain types of information like machine generated event data, logs, and session information that only need to persist in a database for a finite amount of time. To create a TTL index, use the db.collection.createIndex() method with the expireAfterSeconds option on a field whose value is either a date (page 180) or an array that contains date values (page 180). For example, to create a TTL index on the lastModifiedDate field of the eventlog collection, use the following operation in the mongo shell: db.eventlog.createIndex( { "lastModifiedDate": 1 }, { expireAfterSeconds: 3600 } ) Expiration of Data TTL indexes expire documents after the specified number of seconds has passed since the indexed field value; i.e. the expiration threshold is the indexed field value plus the specified number of seconds. If the field is an array, and there are multiple date values in the index, MongoDB uses lowest (i.e. earliest) date value in the array to calculate the expiration threshold. If the indexed field in a document is not a date or an array that holds a date value(s), the document will not expire. If a document does not contain the indexed field, the document will not expire. Delete Operations A background thread in mongod reads the values in the index and removes expired documents from the collection. When the TTL thread is active, you will see delete (page 73) operations in the output of db.currentOp() or in the data collected by the database profiler (page 227). 503 8.2. Index Concepts Behavior TTL Indexes 8.2.2 Index Properties TTL Indexes (page 503) The TTL index is used for TTL collections, which expire data after a period of time. Unique Indexes (page 504) A unique index causes MongoDB to reject all documents that contain a duplicate value for the indexed field. Sparse Indexes (page 505) A sparse index does not index documents that do not have the indexed field.