postgres-fts-backend 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Forest Gregg, 2024 Datamade
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.4
2
+ Name: postgres-fts-backend
3
+ Version: 0.0.1
4
+ Summary: A PostgreSQL Full Text Seach Backend for Haystack
5
+ Author-email: Forest Gregg <fgregg@datamade.us>
6
+ Project-URL: Repository, https://github.com/fgregg/postgres-fts-backend
7
+ Project-URL: Issues, https://github.com/fgregg/postgres-fts-backend/issues
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: django>=5.0
13
+ Requires-Dist: django-haystack>=2.8.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest; extra == "dev"
16
+ Requires-Dist: pytest-django; extra == "dev"
17
+ Requires-Dist: ruff; extra == "dev"
18
+ Requires-Dist: black; extra == "dev"
19
+ Requires-Dist: mypy; extra == "dev"
20
+ Requires-Dist: django-stubs; extra == "dev"
21
+ Dynamic: license-file
22
+
23
+ # postgres-fts-backend
24
+
25
+ A [Django Haystack](https://django-haystack.readthedocs.io/) backend that uses
26
+ PostgreSQL's built-in full-text search. No external search service required.
27
+
28
+ ## Requirements
29
+
30
+ - Python >= 3.12
31
+ - Django >= 5.0
32
+ - django-haystack >= 2.8.0
33
+ - PostgreSQL
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install postgres-fts-backend
39
+ ```
40
+
41
+ Add to `INSTALLED_APPS`:
42
+
43
+ ```python
44
+ INSTALLED_APPS = [
45
+ "django.contrib.postgres",
46
+ "haystack",
47
+ "postgres_fts_backend",
48
+ # ...
49
+ ]
50
+ ```
51
+
52
+ Set a migration module so the generated search index migrations live in
53
+ your project rather than inside the installed package:
54
+
55
+ ```python
56
+ MIGRATION_MODULES = {
57
+ "postgres_fts_backend": "myapp.search_migrations",
58
+ }
59
+ ```
60
+
61
+ Configure Haystack:
62
+
63
+ ```python
64
+ HAYSTACK_CONNECTIONS = {
65
+ "default": {
66
+ "ENGINE": "postgres_fts_backend.PostgresFTSEngine",
67
+ },
68
+ }
69
+ ```
70
+
71
+ To use a search configuration other than `"english"`:
72
+
73
+ ```python
74
+ HAYSTACK_CONNECTIONS = {
75
+ "default": {
76
+ "ENGINE": "postgres_fts_backend.PostgresFTSEngine",
77
+ "SEARCH_CONFIG": "spanish",
78
+ },
79
+ }
80
+ ```
81
+
82
+ ## Other Peculiarities of this backend
83
+
84
+ ### Build indexes through models and migrations
85
+
86
+ ```bash
87
+ python manage.py build_postgres_schema
88
+ python manage.py migrate postgres_fts_backend
89
+ ```
90
+
91
+ Run these two commands again whenever you change a `SearchIndex` definition.
92
+
93
+ ### Fuzzy search
94
+
95
+ Fuzzy queries use PostgreSQL's trigram similarity matching (`pg_trgm`):
96
+
97
+ ```python
98
+ results = SearchQuerySet().filter(author__fuzzy="Janee")
99
+ ```
100
+
101
+ The similarity threshold is controlled by PostgreSQL's
102
+ `pg_trgm.similarity_threshold` setting (default 0.3). To adjust it:
103
+
104
+ ```sql
105
+ ALTER DATABASE mydb SET pg_trgm.similarity_threshold = 0.5;
106
+ ```
107
+
108
+ ### `more_like_this` not implemented
109
+ PostgreSQL FTS doesn't provide any facilities for this. It could be done, but I just need to think more about it.
110
+
111
+ ### `spelling_suggestions` are not supported
@@ -0,0 +1,89 @@
1
+ # postgres-fts-backend
2
+
3
+ A [Django Haystack](https://django-haystack.readthedocs.io/) backend that uses
4
+ PostgreSQL's built-in full-text search. No external search service required.
5
+
6
+ ## Requirements
7
+
8
+ - Python >= 3.12
9
+ - Django >= 5.0
10
+ - django-haystack >= 2.8.0
11
+ - PostgreSQL
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install postgres-fts-backend
17
+ ```
18
+
19
+ Add to `INSTALLED_APPS`:
20
+
21
+ ```python
22
+ INSTALLED_APPS = [
23
+ "django.contrib.postgres",
24
+ "haystack",
25
+ "postgres_fts_backend",
26
+ # ...
27
+ ]
28
+ ```
29
+
30
+ Set a migration module so the generated search index migrations live in
31
+ your project rather than inside the installed package:
32
+
33
+ ```python
34
+ MIGRATION_MODULES = {
35
+ "postgres_fts_backend": "myapp.search_migrations",
36
+ }
37
+ ```
38
+
39
+ Configure Haystack:
40
+
41
+ ```python
42
+ HAYSTACK_CONNECTIONS = {
43
+ "default": {
44
+ "ENGINE": "postgres_fts_backend.PostgresFTSEngine",
45
+ },
46
+ }
47
+ ```
48
+
49
+ To use a search configuration other than `"english"`:
50
+
51
+ ```python
52
+ HAYSTACK_CONNECTIONS = {
53
+ "default": {
54
+ "ENGINE": "postgres_fts_backend.PostgresFTSEngine",
55
+ "SEARCH_CONFIG": "spanish",
56
+ },
57
+ }
58
+ ```
59
+
60
+ ## Other Peculiarities of this backend
61
+
62
+ ### Build indexes through models and migrations
63
+
64
+ ```bash
65
+ python manage.py build_postgres_schema
66
+ python manage.py migrate postgres_fts_backend
67
+ ```
68
+
69
+ Run these two commands again whenever you change a `SearchIndex` definition.
70
+
71
+ ### Fuzzy search
72
+
73
+ Fuzzy queries use PostgreSQL's trigram similarity matching (`pg_trgm`):
74
+
75
+ ```python
76
+ results = SearchQuerySet().filter(author__fuzzy="Janee")
77
+ ```
78
+
79
+ The similarity threshold is controlled by PostgreSQL's
80
+ `pg_trgm.similarity_threshold` setting (default 0.3). To adjust it:
81
+
82
+ ```sql
83
+ ALTER DATABASE mydb SET pg_trgm.similarity_threshold = 0.5;
84
+ ```
85
+
86
+ ### `more_like_this` not implemented
87
+ PostgreSQL FTS doesn't provide any facilities for this. It could be done, but I just need to think more about it.
88
+
89
+ ### `spelling_suggestions` are not supported