MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / create_index

Method create_index

mongoengine/document.py:879–893  ·  view source on GitHub ↗

Creates the given indexes if required. :param keys: a single index key or a list of index keys (to construct a multi-field index); keys may be prefixed with a **+** or a **-** to determine the index ordering :param background: Allows index creation in the bac

(cls, keys, background=False, **kwargs)

Source from the content-addressed store, hash-verified

877
878 @classmethod
879 def create_index(cls, keys, background=False, **kwargs):
880 """Creates the given indexes if required.
881
882 :param keys: a single index key or a list of index keys (to
883 construct a multi-field index); keys may be prefixed with a **+**
884 or a **-** to determine the index ordering
885 :param background: Allows index creation in the background
886 """
887 index_spec = cls._build_index_spec(keys)
888 index_spec = index_spec.copy()
889 fields = index_spec.pop("fields")
890 index_spec["background"] = background
891 index_spec.update(kwargs)
892
893 return cls._get_collection().create_index(fields, **index_spec)
894
895 @classmethod
896 def ensure_indexes(cls):

Callers 5

ensure_indexesMethod · 0.80
test_create_indexMethod · 0.80
test_compare_indexesMethod · 0.80

Calls 4

_build_index_specMethod · 0.80
popMethod · 0.80
_get_collectionMethod · 0.80
updateMethod · 0.45

Tested by 4

test_create_indexMethod · 0.64
test_compare_indexesMethod · 0.64