django-opensearch-models¶
Index your Django models in OpenSearch and keep them in sync automatically.
You describe an index by declaring a Document class against a model, and the library handles the
rest: it builds the OpenSearch mapping from your Django fields, populates the index, and updates it
on every save() and delete() through Django’s signal framework. Search results convert back into
real Django querysets when you need them.
What you get
Declarative documents. A
Documentsubclass maps a Django model to an OpenSearch index — fields, analyzers, index settings and all.Automatic synchronisation. Model changes reach the index through signals, either inline or handed to Celery as background tasks.
Related-model tracking. Declare
related_modelsand edits to aForeignKeytarget re-index the documents that embed it.Management commands. Create, populate, rebuild and delete indices, with zero-downtime rebuilds behind an alias and optional parallel indexing.
Querysets from search results.
.to_queryset()turns a search response back into a Django queryset, ordered to match the search.
Supported versions¶
Supported versions |
|
|---|---|
Python |
3.12, 3.13, 3.14 |
Django |
5.2, 6.0, 6.1 |
>=3.1, <4 |
|
OpenSearch server |
2.19, 3.8 |
Every combination in that table is exercised nightly against a real OpenSearch cluster, under both signal processors.
Where to start¶
Install the app, point it at a cluster, index your first model and search it.
The Document class, the Django inner class, and the hooks that control what gets indexed.
Field types, how Django model fields map onto them, and how to index relationships.
Index objects, zero-downtime rebuilds behind an alias, and the post_index signal.
Every Django setting this app reads, and what happens when you leave it out.
The search_index management command in full.