elasticsearch-dsl-py icon indicating copy to clipboard operation
elasticsearch-dsl-py copied to clipboard

Include link to bulk-helpers for `Document.to_dict()`

Open kjaymiller opened this issue 4 years ago • 1 comments

The docs refer to use of elasticsearch.helpers.bulk as a way to manipulate many items.

This documentation change as a link to the documentation for elasticsearch.helpers.bulk this would provide an easy direction for questions concerning bulk operations such as https://github.com/elastic/elasticsearch-dsl-py/issues/1194#issuecomment-690751569.

Proposed Documentation Change

    def to_dict(self, include_meta=False, skip_empty=True):
        """
        Serialize the instance into a dictionary so that it can be saved in elasticsearch.
        :arg include_meta: if set to ``True`` will include all the metadata
            (``_index``, ``_id`` etc). Otherwise just the document's
            data is serialized. This is useful when passing multiple instances into the `elasticsearch-py`
            `bulk helper <https://elasticsearch-py.readthedocs.io/en/master/helpers.html#bulk-helpers>`
            ``elasticsearch.helpers.bulk`` 
        :arg skip_empty: if set to ``False`` will cause empty values (``None``,
            ``[]``, ``{}``) to be left on the document. Those values will be
            stripped out otherwise as they make no difference in elasticsearch.
        """

kjaymiller avatar Sep 30 '20 18:09 kjaymiller

@kjaymiller elasticsearch-dsl-py uses this under the hood

https://elasticsearch-py.readthedocs.io/en/7.10.0/helpers.html?highlight=actions#elasticsearch.helpers.bulk

ArtemBernatskyy avatar Dec 28 '20 12:12 ArtemBernatskyy

Considering that links to other documentation projects tend to break over time (as the one you included above now is) I think it is best to leave the reference as is. Note that putting elasticsearch.helpers.bulk on Google returns the correct and updated link to documentation in the first result.

miguelgrinberg avatar Apr 26 '24 14:04 miguelgrinberg