Skip to content

Conversation

christophstrobl
Copy link
Member

@christophstrobl christophstrobl commented Mar 26, 2020

Annotation based index creation is now turned OFF by default and needs to be enabled eg. when relying on @GeoSpatialIndexed.

XML Namespace

<mongo:mapping-converter auto-index-creation="true" />

Java Config

@Configuration
public class Config extends AbstractMongoClientConfiguration {

    @Override
    protected boolean autoIndexCreation() {
        return true;
    }
    // ...
}

Programmatic

MongoDatabaseFactory dbFactory = new SimpleMongoClientDatabaseFactory(...);
DefaultDbRefResolver dbRefResolver = new DefaultDbRefResolver(dbFactory);

MongoMappingContext mappingContext = new MongoMappingContext();
mappingContext.setAutoIndexCreation(true);
// ...
mappingContext.afterPropertiesSet();

MongoTemplate template = new MongoTemplate(dbFactory, new MappingMongoConverter(dbRefResolver, mappingContext));

Related ticket: DATAMONGO-2477.

christophstrobl and others added 3 commits March 26, 2020 09:18
Remove warn log for auto-index creation. Remove unused fields. Document index creation in reference documentation.
mp911de pushed a commit that referenced this pull request Mar 26, 2020
mp911de added a commit that referenced this pull request Mar 26, 2020
Remove warn log for auto-index creation. Remove unused fields. Document index creation in reference documentation.

Original pull request: #845.
@mp911de
Copy link
Member

mp911de commented Mar 26, 2020

That's merged and polished now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants