@ConditionalOnMissingBean(name = "mongoDbServiceRegistryTemplate")
    @Bean
    @RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
    public MongoOperations mongoDbServiceRegistryTemplate(
        final CasConfigurationProperties casProperties,
        @Qualifier(CasSSLContext.BEAN_NAME)
        final CasSSLContext casSslContext) {
        val mongo = casProperties.getServiceRegistry().getMongo();
        val factory = new MongoDbConnectionFactory(casSslContext.getSslContext());
        val mongoTemplate = factory.buildMongoTemplate(mongo);
        MongoDbConnectionFactory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
        val collection = mongoTemplate.getCollection(mongo.getCollection());
        val columnsIndex = new TextIndexDefinition.TextIndexDefinitionBuilder().onField("id")
            .onField("serviceId").onField("name").build();
        MongoDbConnectionFactory.createOrUpdateIndexes(mongoTemplate, collection, List.of(columnsIndex));
        return mongoTemplate;
    }
This is {@link CasMongoDbServiceRegistryAutoConfiguration}.

@author Misagh Moayyed
@since 5.0.0
support/cas-server-support-mongo-service-registry/src/main/java/org/apereo/cas/config/CasMongoDbServiceRegistryAutoConfiguration.java