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 Document subclass 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_models and edits to a ForeignKey target 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

opensearch-py

>=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

Quickstart

Install the app, point it at a cluster, index your first model and search it.

Quickstart
Documents

The Document class, the Django inner class, and the hooks that control what gets indexed.

Documents
Fields

Field types, how Django model fields map onto them, and how to index relationships.

Fields
Indices

Index objects, zero-downtime rebuilds behind an alias, and the post_index signal.

Indices
Settings

Every Django setting this app reads, and what happens when you leave it out.

Settings
Commands

The search_index management command in full.

Management commands