Application of TTL indexes can be in Shopping Carts, Login sessions, Event logs etc where the data needs to be retained only for a certain . Mongodb can actually set the expiration time of data just like Redis1. In that below case for nested object spring data mongodb creating multiple TTL index for Class(ClassA). TTL Monitor is a separate thread that runs periodically (usually every minute) and scans a collection, that has a TTL index defined, for any expired documents and removes them in the background. 文本索引只有一个, 所有的注解TextIndexed 的字段都会组合到一个文本索引中。. A background thread in MongoDB reads the values in the index and removes expired documents from the collection (usually every minute). Modified 2 years, 4 months ago. Currently, TTL index can only be established on a single field. The repository follows the Spring Data-centric approach and comes with more flexible and complex API operations, based on the well-known access patterns in all Spring Data projects. Spring Data MongoDB how to set index ttl from system property In previous versions or MongoDB versions with featureCompatibilityVersion (fCV) set to "4.0", index names must fall within the limit. Expire Data from Collections by Setting TTL — MongoDB Manual MongoDB 2.2 or higher supports TTL (Time-To-Live) indexes. 2. Update TTL Indexed Field expiry date later - MongoDB MongoDB Indexes with Spring Data | Lanky Dan Blog Expired data may exist beyond the 60 second period between runs of the TTL monitor. MongoDB Auto Expire Documents - DEV Community /**Method ensures that there is a TTL index on {@literal expireAt} field. 2. To expire data after a specified number of seconds has passed since the indexed field, create a TTL index on a field that holds values of BSON date type or an array of BSON date-typed objects and specify a positive non-zero value in the expireAfterSeconds field. How to disable spring-data-mongodb autoconfiguration in spring-boot. Indexes. But those does not work with " index" annotation on sub-class. Spring data mongo index - 简书