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.14

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.14
File Size Uploaded
postgres_fts_backend-0.0.14.tar.gz 42.8 kB Details

Built distribution (wheel)

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

Total release size: 61.7 kB

Release files / postgres_fts_backend-0.0.14.tar.gz

Download URL postgres_fts_backend-0.0.14.tar.gz
Size 42.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4beca96f8202bbe4267733cc11f0341c79d5099c5e200bbdbce818176be1dcaf
BLAKE2b-256 checksum
How to use checksums
c194ed369dfc74bc6390f2479f6bff9b7c37df852480d45d2ecb867e5f7727cb
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.14-py3-none-any.whl

Download URL postgres_fts_backend-0.0.14-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8295ab9c3a46c748a5d1e988eb782feb028837d1ec981d96aa9ad01b1155cd72
BLAKE2b-256 checksum
How to use checksums
bda6cc319c61676331d1305c3ab86083c19d912f39272de17fe56de893fb6d59
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.14 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