A PostgreSQL Full Text Seach Backend for Haystack
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file postgres_fts_backend-0.0.4.tar.gz.
File metadata
- Download URL: postgres_fts_backend-0.0.4.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b152f855c9a57f04db66711c064e9f66245ee0a43c86d599e8622fe3acd0620
|
|
| MD5 |
c91f17d1a66acf98fff3a37b689ab794
|
|
| BLAKE2b-256 |
fe35dabf91677eb7cf40926e6b88f9ec1c1acc9a45e29be5d78529fc95cd9af0
|
Provenance
The following attestation bundles were made for postgres_fts_backend-0.0.4.tar.gz:
Publisher:
release.yml on fgregg/postgres-fts-backend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
postgres_fts_backend-0.0.4.tar.gz -
Subject digest:
2b152f855c9a57f04db66711c064e9f66245ee0a43c86d599e8622fe3acd0620 - Sigstore transparency entry: 915745903
- Sigstore integration time:
-
Permalink:
fgregg/postgres-fts-backend@4732ac48742fcf267ace96d9b8cc5e41aa887ba3 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/fgregg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4732ac48742fcf267ace96d9b8cc5e41aa887ba3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file postgres_fts_backend-0.0.4-py3-none-any.whl.
File metadata
- Download URL: postgres_fts_backend-0.0.4-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c976c0e103161b4e19d9cc525ea3eab764ba8ad1f140653af658d9e3910e280
|
|
| MD5 |
074b8da08dc1414b0b260a24e9c757b4
|
|
| BLAKE2b-256 |
bd30d8c51cc8e1ab735725fb0f9fc1e6b6d20c0477a43c4392ad1ecba348e216
|
Provenance
The following attestation bundles were made for postgres_fts_backend-0.0.4-py3-none-any.whl:
Publisher:
release.yml on fgregg/postgres-fts-backend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
postgres_fts_backend-0.0.4-py3-none-any.whl -
Subject digest:
6c976c0e103161b4e19d9cc525ea3eab764ba8ad1f140653af658d9e3910e280 - Sigstore transparency entry: 915745963
- Sigstore integration time:
-
Permalink:
fgregg/postgres-fts-backend@4732ac48742fcf267ace96d9b8cc5e41aa887ba3 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/fgregg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4732ac48742fcf267ace96d9b8cc5e41aa887ba3 -
Trigger Event:
release
-
Statement type: