Documentation for new-style indices
This commit is contained in:
parent
40df08c74c
commit
9a2cf206b2
@ -341,9 +341,10 @@ Indexes
|
|||||||
You can specify indexes on collections to make querying faster. This is done
|
You can specify indexes on collections to make querying faster. This is done
|
||||||
by creating a list of index specifications called :attr:`indexes` in the
|
by creating a list of index specifications called :attr:`indexes` in the
|
||||||
:attr:`~mongoengine.Document.meta` dictionary, where an index specification may
|
:attr:`~mongoengine.Document.meta` dictionary, where an index specification may
|
||||||
either be a single field name, or a tuple containing multiple field names. A
|
either be a single field name, a tuple containing multiple field names, or a
|
||||||
direction may be specified on fields by prefixing the field name with a **+**
|
dictionary containing a full index definition. A direction may be specified on
|
||||||
or a **-** sign. Note that direction only matters on multi-field indexes. ::
|
fields by prefixing the field name with a **+** or a **-** sign. Note that
|
||||||
|
direction only matters on multi-field indexes. ::
|
||||||
|
|
||||||
class Page(Document):
|
class Page(Document):
|
||||||
title = StringField()
|
title = StringField()
|
||||||
@ -352,6 +353,21 @@ or a **-** sign. Note that direction only matters on multi-field indexes. ::
|
|||||||
'indexes': ['title', ('title', '-rating')]
|
'indexes': ['title', ('title', '-rating')]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
If a dictionary is passed then the following options are available:
|
||||||
|
|
||||||
|
:attr:`fields` (Default: None)
|
||||||
|
The fields to index. Specified in the same format as described above.
|
||||||
|
|
||||||
|
:attr:`types` (Default: True)
|
||||||
|
Whether the index should have the :attr:`_types` field added automatically
|
||||||
|
to the start of the index.
|
||||||
|
|
||||||
|
:attr:`sparse` (Default: False)
|
||||||
|
Whether the index should be sparse.
|
||||||
|
|
||||||
|
:attr:`unique` (Default: False)
|
||||||
|
Whether the index should be sparse.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
Geospatial indexes will be automatically created for all
|
Geospatial indexes will be automatically created for all
|
||||||
:class:`~mongoengine.GeoPointField`\ s
|
:class:`~mongoengine.GeoPointField`\ s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user