In typical scenario using class Index on a Document class is sufficient to perform any action. In a few cases though it can be useful to manipulate an Index object directly.

To define an Elasticsearch index you must instantiate a elasticsearch_dsl.Index class and set the name and settings of the index. After you instantiate your class, you need to associate it with the Document you want to put in this Elasticsearch index and also add the registry.register_document decorator.

from elasticsearch_dsl import Index
from django_elasticsearch_dsl import Document
from .models import Car, Manufacturer

# The name of your index
car = Index('cars')
# See Elasticsearch Indices API reference for available settings

class CarDocument(Document):
    class Django:
        model = Car
        fields = [

class ManufacturerDocument(Document):
    class Index:
        name = 'manufacture'
        settings = {'number_of_shards': 1,
                    'number_of_replicas': 0}

    class Django:
        model = Manufacturer
        fields = [

When you execute the command:

$ ./ search_index --rebuild

This will create two index named cars and manufacture in Elasticsearch with appropriate mapping.

** If your model have huge amount of data, its preferred to use parallel indexing. To do that, you can pass –parallel flag while reindexing or populating. **


  • django_elasticsearch_dsl.signals.post_index

    Sent after document indexing is completed. (not applicable for parallel indexing). Provides the following arguments:


    A subclass of django_elasticsearch_dsl.documents.DocType used to perform indexing.


    A django_elasticsearch_dsl.documents.DocType subclass instance.


    A generator containing document data that were sent to elasticsearch for indexing.


    The response from bulk() function of elasticsearch-py, which includes success count and failed count or error list.