com.mongodb.CommandFailureException: { \"serverUsed\" : \"localhost:27017\" , \"createdCollectionAutomatically\" : true , \"numIndexesBefore\" : 1 , \"ok\" : 0.0 , \"err
You can not disable indexing as MongoDB will always create an index for _id
. Shorten your collection name instead - saves you some typing too
You can pass an index name as parameter to ensureIndex:
db.collection.ensureIndex({"birds.parrots.macaw.blue.id": 1}, {name:"myIndex1"});
db.collection.ensureIndex({"birds.parrots.macaw.blue.id": 1, "field2": 1}, {name:"myIndex1"});