Skip to content

Commit

Permalink
Document the _doc_type attribute on DocType
Browse files Browse the repository at this point in the history
  • Loading branch information
honzakral committed Apr 23, 2015
1 parent 493c27c commit 07dc9ad
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/persistence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,30 @@ To retrieve an existing document use the ``get`` class method:
# and save the changes into the cluster again
first.save()
All the information about the ``DocType``, including its ``Mapping`` can be
accessed through the ``_doc_type`` attribute of the class:

.. code:: python
# name of the type and index in elasticsearch
Post._doc_type.name
Post._doc_type.index
# the raw Mapping object
Post._doc_type.mapping
# the optional name of the parent type (if defined)
Post._doc_type.parent
The ``_doc_type`` attribute is also home to the ``refresh`` method which will
update the mapping on the ``DocType`` from elasticsearch. This is very useful
if you use dynamic mappings and want the class to be aware of those fields (for
example if you wish the ``Date`` fields to be properly (de)serialized):

.. code:: python
Post._doc_type.refresh()
Search
~~~~~~

Expand Down

0 comments on commit 07dc9ad

Please sign in to comment.