Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Mar 302011
 

Create an index on a document in MongoDB

Answer:

To create an index on a document in MongoDB, you can enter the shell and execute the statement like:

db.test.ensureIndex({ "fieldName": 1 })

(Assume you need to create index on fieldName of the test collection.)

That's easy?

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>