ensureIndex is running fine but createIndex is throwing error.

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.10.1
    • Component/s: Authentication
    • None
    • Environment:
      Client on Windows and Server on Linux, Database is 2.4.8.
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When i run use DBCollection.ensureIndex() option it is creating Index without any issue but this method is depreciated and it is suggested to use createIndex method. Using createIndex is throwing the following Exception.

      I am trying to create TTL Collection using following DBObjects.

      BasicDBObject ttlIndexObj=new BasicDBObject("actionDate", 1);
      BasicDBObject ttlIndexObjOption=new BasicDBObject("name", "actionDate_ttl_7_days").append("expireAfterSeconds", 204800);
      
      com.mongodb.MongoException: not authorized to create index on 
      	at com.mongodb.CommandResult.getException(CommandResult.java:100)
      	at com.mongodb.CommandResult.throwOnError(CommandResult.java:134)
      	at com.mongodb.DBTCPConnector._checkWriteError(DBTCPConnector.java:142)
      	at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:183)
      	at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:155)
      	at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:270)
      	at com.mongodb.DBApiLayer$MyCollection.createIndex(DBApiLayer.java:365)
      	at com.mongodb.DBCollection.createIndex(DBCollection.java:484)
      	at com.fitch.financial_statement_api.dao.NicknameChangeLogDAOTest.tesTTLIndex(NicknameChangeLogDAOTest.java:88)
      

        1. MongoIssueTest.java
          2 kB
          Rajesh Sharma

            Assignee:
            Ross Lawley
            Reporter:
            Rajesh Sharma
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: