About Elasticsearch Indices

When using django-elasticsearch-dsl, create the names of your indices combined of:

  • project name, e.g. "myproject"
  • environment name, e.g. "staging"
  • app name (optionally) and model name, e.g. "blog_post"

Just like this:

@registry.register_document
class BlogPostDocument(Document):
    class Index:
        name = f"myproject_{settings.ENVIRONMENT}_blog_post"
        settings = {
            "number_of_shards": 1,
            "number_of_replicas": 0,
        }
    # …

This way, you can share the same Elasticsearch server for different projects or project environments.

Tips and Tricks Programming Architecture Development Django 5.2 Django 4.2 Django 3.2 Elasticsearch

Django/Python Consulting

If you have a specific Django challenge or integration you'd like to solve, I'd be happy to help. Book a free 30-minute call to discuss your project, see if we're a good fit, and explore the best approach for your needs. After the call, you'll receive a tailored cost estimate based on what we discuss.