Announcement Announcement Module
Collapse
No announcement yet.
Prevent Mongo indexing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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;
          }

      Comment


      • #4
        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

        Comment

        Working...
        X