modelsearch
A library for indexing Django models with Elasicsearch, OpenSearch or database and searching them with the Django ORM.
What it is and what it does
Django ModelSearch is a search indexing layer for Django that lets you index your models into Elasticsearch, OpenSearch, or your existing database (PostgreSQL FTS, MySQL FTS, MariaDB FTS, SQLite FTS5) and then query them through the familiar Django ORM. Instead of writing raw search queries, you call `.search()` on a QuerySet just like you would `.filter()`, and the library translates that into the appropriate backend query.
It was built into Wagtail CMS since 2014 and extracted as a standalone package in March 2025. The library handles index synchronization via Django signals, supports zero-downtime index rebuilds using aliases, and integrates with Django's pagination and filtering ecosystem. You define searchable fields on your models with optional per-field boosting, filter fields for fast faceting, and can pull content from related models into the index.
Use it for:
- Build a product catalog search that works across PostgreSQL, Elasticsearch, or SQLite without rewriting query logic for each backend.
- Add autocomplete and fuzzy search to a Django admin or user-facing search form with faceted results.
- Index large text fields (articles, documentation, logs) and search them with phrase queries and field-specific relevance tuning.
- Migrate search from database FTS to Elasticsearch for performance without changing application code.
- Combine full-text search with Django filters and pagination in a single QuerySet chain.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Indexes Django models into Elasticsearch, OpenSearch, or native database full-text search, then queries them through the Django ORM with support for filtering, faceting, and fuzzy search.
Yes. The package is actively maintained, has low install friction, carries a permissive license, and solves a real problem—letting you write search queries in Django ORM syntax regardless of backend. It's production-ready (marked stable, extracted from Wagtail's proven codebase), has no known vulnerabilities, and supports modern Python versions. Install it if you need flexible, backend-agnostic search on Django models.
Install
modelsearch on PyPI
pip
pip install modelsearchuv
uv add modelsearchpoetry
poetry add modelsearchInstalling modelsearch
Before you install
Low friction: pure Python wheel with only Django and django-tasks as runtime dependencies. Actively maintained since March 2025 with recent commits and no known vulnerabilities.
License in practice
BSD-3-Clause (permissive): you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install modelsearch
# settings.py
INSTALLED_APPS = [
'modelsearch',
'django.contrib.postgres', # if using PostgreSQL
]
# models.py
from modelsearch import index
from modelsearch.queryset import SearchableQuerySetMixin
class SongQuerySet(SearchableQuerySetMixin, models.QuerySet):
pass
class Song(index.Indexed, models.Model):
name = models.TextField()
search_fields = [index.SearchField('name', boost=2.0)]
objects = SongQuerySet.as_manager()
# Then search
Song.objects.search("query")
Requires Python 3.10+; if using PostgreSQL, django.contrib.postgres must be in INSTALLED_APPS; run `django-admin rebuild_modelsearch_index` to initialize indexes.
Verify before relying
- Whether django-tasks is a hard runtime requirement or optional for background indexing.
- Performance characteristics and scaling limits with large datasets or high query volume.
- Compatibility matrix details for specific Elasticsearch/OpenSearch versions beyond the documented 7.x, 8.x, 9.x and 2.x, 3.x ranges.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — Django, django-tasks |
| Maintenance | actively maintained — 3 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 534,200/month — #6,137 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: modelsearch-1.3.2-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
django-elasticsearch-dslIndexes Django model instances into…
permissive · top 15,000 on PyPI
django-haystackHaystack provides a unified search API for…
permissive · top 15,000 on PyPI
sqlalchemy-searchableAdds fulltext search capabilities to SQLAlchemy…
permissive · top 15,000 on PyPI
django-ordered-modelAdds ordering and reordering capabilities to…
permissive · top 15,000 on PyPI
django-opensearch-dslIndexes Django model instances into OpenSearch…
permissive · top 15,000 on PyPI
typesensePython client library for Typesense search…
permissive · top 5,000 on PyPI
django-filterDjango-filter adds dynamic QuerySet filtering…
permissive · top 5,000 on PyPI
django-mysqlDjango-MySQL extends Django's ORM with MySQL…
permissive · top 15,000 on PyPI
WhooshWhoosh is a pure-Python full-text search and…
permissive · top 5,000 on PyPI
djangoqlDjangoQL provides an advanced search query…
permissive · top 15,000 on PyPI