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

ensureIndex is running fine but createIndex is throwing error.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 2.10.1
    • Authentication
    • None
    • Client on Windows and Server on Linux, Database is 2.4.8.

    Description

      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)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: