Skip to content

Commit a25a044

Browse files
committed
Configure Django to use Elasticsearch
1 parent 4c20510 commit a25a044

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ mailman3_config:
117117
class: mailman.database.postgresql.PostgreSQLDatabase
118118
url: postgresql://mailman3_core:[email protected]/mailman3_core
119119
mailman3_django_config:
120+
haystack_engine: haystack.backends.elasticsearch7_backend.Elasticsearch7SearchEngine
120121
secret_key: supersecret
121122
# Don't define hyperkitty_attachment_folder. If not set, it will store attachments in the db.
122123
# hyperkitty_attachment_folder: "{{ mailman3_web_var_dir }}/attachments"

defaults/main.yml

+4
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ __mailman3_pip_packages:
360360
- mailman
361361
- mailman-web
362362
- mailman-hyperkitty # ??
363+
- elasticsearch==7.17.9
363364
- "{{ mailman3_python_wsgi_package }}"
364365

365366
# Packages to install from PyPI if using the pip install method. Automatically includes libsass if mailman3_use_pysassc
@@ -467,3 +468,6 @@ elasticsearch_http_port: 9200
467468
elasticsearch_extra_options: ''
468469
elasticsearch_heap_size_min: 1g
469470
elasticsearch_heap_size_max: 2g
471+
# used by Django, not necessarily by elasticsearch itself:
472+
elasticsearch_index_name: mailman
473+
elasticsearch_url: "http://127.0.0.1:9200/"

templates/settings.py.j2

+10
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,23 @@ EMAIL_FILE_PATH = os.path.join("{{ mailman3_web_var_dir }}", 'emails')
135135
#
136136
# Full-text search engine
137137
#
138+
{% if 'Elasticsearch' in __mailman3_django_config_merged.haystack_engine %}
139+
HAYSTACK_CONNECTIONS = {
140+
'default': {
141+
'ENGINE': '{{ __mailman3_django_config_merged.haystack_engine }}',
142+
"URL": "{{ elasticsearch_url }}",
143+
"INDEX_NAME": "{{ elasticsearch_index_name }}",
144+
},
145+
}
146+
{% else %}
138147
HAYSTACK_CONNECTIONS = {
139148
'default': {
140149
'ENGINE': '{{ __mailman3_django_config_merged.haystack_engine }}',
141150
'PATH': os.path.join("{{ mailman3_web_var_dir }}", "fulltext_index"),
142151
},
143152
}
144153
{% endif %}
154+
{% endif %}
145155
{% if __mailman3_django_config_merged.socialaccount_providers is defined %}
146156

147157
{% for provider in __mailman3_django_config_merged.socialaccount_providers | sort %}

0 commit comments

Comments
 (0)