Problem: mongodb ttl index is not been creating via Spring Data
I have a spring-boot application and MongoDB as database.
I have an entity class:
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document(COLLECTION_NAME)
public class PersonEntity {
public static final String COLLECTION_NAME = "person_info";
private static final String PERSON_NAME = "person_name";
@Id
private PersonId id;
@Field(name = PERSON_NAME)
private String personName;
@Indexed(name = "ttl_index", expireAfterSeconds=20)
private LocalDateTime date;
}
And I persist a new document to MongoDB using this repository:
public interface SellerRequestInfoRepository extends ReactiveMongoRepository<PersonEntityEntity, PersonId> {}
using
personRepository.save(entity);
But the TTL index is not created on MongoDB after insetting the Person document:
Please, advice, what I am doing wrong