Reputation: 5454
I created a TTL index on a collection probably a year ago and I can't remember what I called it. I'm finding that I no longer need it and would like to delete it. How do I find and delete this TTL Index? Using db.collection.getIndexes()
only provides vague names and none seem like the name I used at the time.
Upvotes: 3
Views: 2962
Reputation: 17498
I needed to do this myself. But there is no command to filter out only the TTL indexes. So I just looped through the indexes and find the TTL indexes by expireAfterSeconds
property.
var ttlIndexes = db.ttldemo.getIndexes().filter(function(i){
return i.hasOwnProperty('expireAfterSeconds');
});
Upvotes: 2