Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support disabling elasticsearch #834

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions taccsite_cms/_settings/search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Configure search plugins"""

########################
# TACC: SEARCH
########################

PORTAL_ES_ENABLED = True

SEARCH_PATH = '/search'

if PORTAL_ES_ENABLED:
# Elasticsearch
SEARCH_QUERY_PARAM_NAME = 'query_string'
else:
# Google
SEARCH_QUERY_PARAM_NAME = 'q'

########################
# ELASTICSEARCH
########################

if PORTAL_ES_ENABLED:
ES_AUTH = 'username:password'
ES_HOSTS = 'http://elasticsearch:9200'
ES_INDEX_PREFIX = 'cms-dev-{}'
ES_DOMAIN = 'http://localhost:8000'

# Elasticsearch Indexing
HAYSTACK_ROUTERS = ['aldryn_search.router.LanguageRouter', ]
HAYSTACK_SIGNAL_PROCESSOR = 'taccsite_cms.signal_processor.RealtimeSignalProcessor'
ALDRYN_SEARCH_DEFAULT_LANGUAGE = 'en'
ALDRYN_SEARCH_REGISTER_APPHOOK = True
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': ES_HOSTS,
'INDEX_NAME': ES_INDEX_PREFIX.format('cms'),
'KWARGS': {'http_auth': ES_AUTH}
}
}

########################
# DJANGO CMS
########################

if PORTAL_ES_ENABLED:
_INSTALLED_APPS = [
'haystack', # search index
'aldryn_apphooks_config', # search index & django CMS Blog
]
else:
_INSTALLED_APPS = []
38 changes: 6 additions & 32 deletions taccsite_cms/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
from taccsite_cms._settings.form_plugin import (
_INSTALLED_APPS as form_plugin_INSTALLED_APPS
)
from taccsite_cms._settings.search import *
from taccsite_cms._settings.search import (
_INSTALLED_APPS as search_INSTALLED_APPS
)

########################
# DJANGO
Expand Down Expand Up @@ -172,36 +176,6 @@ def gettext(s): return s
GOOGLE_ANALYTICS_PROPERTY_ID = "UA-123ABC@%$&-#"
GOOGLE_ANALYTICS_PRELOAD = True

########################
# TACC: SEARCH
########################

# To customize site search
SEARCH_PATH = '/search'
SEARCH_QUERY_PARAM_NAME = 'query_string'

########################
# ELASTICSEARCH
########################

ES_AUTH = 'username:password'
ES_HOSTS = 'http://elasticsearch:9200'
ES_INDEX_PREFIX = 'cms-dev-{}'
ES_DOMAIN = 'http://localhost:8000'

# Elasticsearch Indexing
HAYSTACK_ROUTERS = ['aldryn_search.router.LanguageRouter', ]
HAYSTACK_SIGNAL_PROCESSOR = 'taccsite_cms.signal_processor.RealtimeSignalProcessor'
ALDRYN_SEARCH_DEFAULT_LANGUAGE = 'en'
ALDRYN_SEARCH_REGISTER_APPHOOK = True
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': ES_HOSTS,
'INDEX_NAME': ES_INDEX_PREFIX.format('cms'),
'KWARGS': {'http_auth': ES_AUTH}
}
}

########################
# TACC: BRANDING
Expand Down Expand Up @@ -481,9 +455,9 @@ def gettext(s): return s
'djangocms_bootstrap4.contrib.bootstrap4_tabs',
'djangocms_bootstrap4.contrib.bootstrap4_utilities',

] + search_INSTALLED_APPS + [

# miscellaneous
'haystack', # search index
'aldryn_apphooks_config', # search index & django CMS Blog
'test_without_migrations', # run tests faster

] + form_plugin_INSTALLED_APPS + [
Expand Down