Skip to main content

postgres-fts-backend

A Django Haystack backend that uses PostgreSQL's built-in full-text search. No external search service required.

Requirements

  • Python >= 3.12
  • Django >= 5.0
  • django-haystack >= 2.8.0
  • PostgreSQL

Installation

pip install postgres-fts-backend

Add to INSTALLED_APPS:

INSTALLED_APPS = [
    "django.contrib.postgres",
    "haystack",
    "postgres_fts_backend",
    # ...
]

Set a migration module so the generated search index migrations live in your project rather than inside the installed package:

MIGRATION_MODULES = {
    "postgres_fts_backend": "myapp.search_migrations",
}

Configure Haystack:

HAYSTACK_CONNECTIONS = {
    "default": {
        "ENGINE": "postgres_fts_backend.PostgresFTSEngine",
    },
}

To use a search configuration other than "english":

HAYSTACK_CONNECTIONS = {
    "default": {
        "ENGINE": "postgres_fts_backend.PostgresFTSEngine",
        "SEARCH_CONFIG": "spanish",
    },
}

Other Peculiarities of this backend

Build indexes through models and migrations

python manage.py build_postgres_schema
python manage.py migrate postgres_fts_backend

Run these two commands again whenever you change a SearchIndex definition.

Fuzzy search

Fuzzy queries use PostgreSQL's trigram similarity matching (pg_trgm):

results = SearchQuerySet().filter(author__fuzzy="Janee")

The similarity threshold is controlled by PostgreSQL's pg_trgm.similarity_threshold setting (default 0.3). To adjust it:

ALTER DATABASE mydb SET pg_trgm.similarity_threshold = 0.5;

more_like_this not implemented

PostgreSQL FTS doesn't provide any facilities for this. It could be done, but I just need to think more about it.

spelling_suggestions are not supported

Metadata

Release files for postgres-fts-backend 0.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for postgres-fts-backend 0.0.13
File Size Uploaded
postgres_fts_backend-0.0.13.tar.gz 42.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for postgres-fts-backend 0.0.13
File Interpreter ABI Platform
postgres_fts_backend-0.0.13-py3-none-any.whl Python 3 none any Details

Total release size: 61.5 kB

Release files / postgres_fts_backend-0.0.13.tar.gz

Download URL postgres_fts_backend-0.0.13.tar.gz
Size 42.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cfddbf1a0adca048085082f9135922fe5ada383624ed23eb3eff8ec6c0919f6c
BLAKE2b-256 checksum
How to use checksums
7ff88fc2b26bcd3334cbc4f92999adeb03b64caa3d5e90b59fe18e9fc433b8ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Release files / postgres_fts_backend-0.0.13-py3-none-any.whl

Download URL postgres_fts_backend-0.0.13-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcec497087f3ae264dbb7ee045d534ad6ce48cc9d9650da8f7bd071036632fe0
BLAKE2b-256 checksum
How to use checksums
2aa2c08270bba4776fca5a4dae9344a0d5b9b43b0e68f1bce62e7ed5d9491257
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.13 This release

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page