I went through https://docs.spring.io/spring-data/mongodb/docs/2.2.0.RC1/reference/html/#mapping-usage and other sources on the web, but the solution did not worked for me.<
But the solution doensn't work well, at least within the reactive context. The mongoMappingContext.getPersistentEntities() is empty at this time. Only auto-index-creation: true (or even mongoMappingContext.setAutoIndexCreation(true)) ensure the creation of indexes.