[Django]-Creating indexes – MongoDB

8👍

Thanks to skot in #mongodb!!

One solution is:

[...].ensureIndex({"actions.time":1})

for creating an index on the time field within the actions list.

12👍

Example for pymongo:

import pymongo

mongo = pymongo.Connection('localhost')
collection = mongo['database']['hosts']
collection.ensure_index('host_name', unique=True)
👤jpoppe

Leave a comment