Results 1 to 4 of 4

Thread: Prevent Mongo indexing

  1. #1

    Default Prevent Mongo indexing

    Hi there.

    I'm using Spring Datastore Document and MongoDB. My Problem is that I can't (should) change the indexing of mongo but for every event defined in my extended MongoRepository (like findBySomething(String some)) an index is created. So I can't use it. Is there a way to prevent creating the index by spring-data-mongodb?

  2. #2
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

    MongoRepositoryFactoryBean currently adds the IndexEnsuringQueryCreationListener inside createRepositoryFactory(). So you could easily create a sub-class of the FactoryBean override the method and then let the namespace work with your repository class (see the factory-class attribute in the namespace).

    We definitely should make this more convenient by being able to switch that of with a simple flag at the namespace. Feel free to open a JIRA ticket for this.

  3. #3

    Default

    I can't overwrite it, cause it requires access to private variable template:

    PHP Code:
    public class MyMongoRepositoryFactoryBean<extends Repository<SID>, SID extends Serializable> extends MongoRepositoryFactoryBean<TSID> {
        @
    Override
        
    protected RepositoryFactorySupport createRepositoryFactory() {
            
    MongoRepositoryFactory factory = new MongoRepositoryFactory(template);
            return 
    factory;
        }


  4. #4
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

    You could try overriding the setter for the template and shadow the field. Admittedly this way the hack even becomes an ugly hack . I've created a ticket to add the flag to disable repository method index creation [0], as well as one to improve extensibility of MongoRepositoryFactoryBean [1].

    [0] https://jira.springsource.org/browse/DATADOC-188
    [1] https://jira.springsource.org/browse/DATADOC-189

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •