KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to create compound index on Age and Name in MongoDB through Java driver and here is my syntax: coll.ensureIndex(new BasicDBObject("Age", 1),new BasicDBObject("Name", -1)); List <DBObject> list = coll.getIndexInfo(); for (DBObject o : list) { System.out.println(o); } but it create only 1 index not compund index and give me result this: { "v" : 1 , "key" : { "_id" : 1} ,"ns" :"EmployeeData.EmpPersonalData", "name":"_id_"} { "v" : 1 , "key" : { "Age" : 1} , "ns" : "EmployeeData.EmpPersonalData" , "name" : "Age_1" , "Name" : -1} So how can compund index on collection can be created through java driver?
Tags (comma-separated)
Save Edits
Cancel