diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java index 5bc7b83d009..ebc017039b0 100644 --- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java +++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java @@ -175,12 +175,23 @@ public class MongoSessionIdManager extends AbstractSessionIdManager _server = server; _sessions = sessions; - _sessions.ensureIndex( - BasicDBObjectBuilder.start().add("id",1).get(), - BasicDBObjectBuilder.start().add("unique",true).add("sparse",false).get()); - _sessions.ensureIndex( - BasicDBObjectBuilder.start().add("id",1).add("version",1).get(), - BasicDBObjectBuilder.start().add("unique",true).add("sparse",false).get()); + DBObject idKey = BasicDBObjectBuilder.start().add("id", 1).get(); + _sessions.createIndex(idKey, + BasicDBObjectBuilder.start() + .add("name", "id_1") + .add("ns", _sessions.getFullName()) + .add("sparse", false) + .add("unique", true) + .get()); + + DBObject versionKey = BasicDBObjectBuilder.start().add("id", 1).add("version", 1).get(); + _sessions.createIndex(versionKey, BasicDBObjectBuilder.start() + .add("name", "id_1_version_1") + .add("ns", _sessions.getFullName()) + .add("sparse", false) + .add("unique", true) + .get()); + }