<commit_before>.. _persistence:

Persistence
===========

You can use the dsl library to define your mappings and a basic persistent
layer for your application.

.. _doc_type:

Document
--------

If you want to create a model-like wrapper around your documents, use the
``Document`` class. It can also be used to create all the necessary mappings and
settings in elasticsearch (see :ref:`life-cycle` for details).

.. code:: python<commit_msg>Add link to examples from persistence docs<commit_after>.. _persistence:

Persistence
===========

You can use the dsl library to define your mappings and a basic persistent
layer for your application.

For more comprehensive examples have a look at the examples_ directory in the
repository.

.. _examples: https://github.com/elastic/elasticsearch-dsl-py/tree/master/examples

.. _doc_type:

Document
--------

If you want to create a model-like wrapper around your documents, use the
``Document`` class. It can also be used to create all the necessary mappings and
settings in elasticsearch (see :ref:`life-cycle` for details).

.. code:: python
{'fraction_non_alphanumeric': 0.1018348623853211, 'fraction_numerical': 0.0, 'mean_word_length': 4.122065727699531, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3177108', 'n_tokens_mistral': 289, 'n_tokens_neox': 280, 'n_words': 139}