Você pode fazer isso usando
@Indexed expireAfterSeconds da anotação atributo sobre um campo cujo tipo é Date .Aproximadamente:@Document
public class SomeEntity {
String id;
@Field
@Indexed(name="someDateFieldIndex", expireAfterSeconds=3600)
Date someDateField;
// rest of code here
}
Ou manipulando um
MongoTemplate :mongoTemplate
.indexOps(SomeEntity.class)
.ensureIndex(new Index().on("someDateField", Sort.Direction.ASC).expire(3600));