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.x Django 4.2 Django 3.2 Elasticsearch
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django GDPR Cookie Consent app
For Django websites that use cookies.