Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1261

ensureIndex is running fine but createIndex is throwing error.

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

      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)
      

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            rajeshks117 Rajesh Sharma
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: