There are a couple things to check:
- Were you just following the docs to a T and tried to create an index on a
status
field which doesn't actually exist in your documents? (had to atleast ask...)
- Does the
status
field contain JUST dates
? It can theoretically be mixed, but only documents with a date type would be considered for expiration.
- Have you checked your collection indexes to make sure the index was properly created?
To check for the index from the console run: db.collection.getIndexes()
. If the index was created successfully, then double check you have the corresponding status
fields in your documents and that they are proper dates.
Adding the index alone, doesn't create the date field for you - you would need to add it to the documents or use an existing date field that is not part of any other index.
Also note, from the docs:
TTL indexes expire data by removing documents in a background task
that runs every 60 seconds
So, if you have a 120 second
expiration, bear in mind, that its possible the documents could remain for 120 seconds
up to 179 seconds
, give or take, depending on when the document expired and the background task last ran.
edit: As noted in the comments - a collection itself cannot be removed based on a TTL index, the index only expires the documents in the collection.