From 8a99c92810a13caaf1104ea70ff140d3e196be90 Mon Sep 17 00:00:00 2001 From: nsantacruz Date: Tue, 28 Nov 2023 11:28:54 +0200 Subject: [PATCH] refactor(search): change SEARCH_ADMIN to SEARCH_URL which more clearly defines what the variable is --- build/ci/integration-values.yaml | 2 +- build/ci/production-values.yaml | 2 +- build/ci/sandbox-values.yaml | 2 +- .../templates/configmap/local-settings-file.yaml | 2 +- helm-chart/sefaria-project/values.yaml | 4 +--- reader/views.py | 2 +- sefaria/helper/search.py | 4 ++-- sefaria/local_settings_ci.py | 2 +- sefaria/local_settings_example.py | 2 +- sefaria/search_ES6.py | 4 ++-- 10 files changed, 12 insertions(+), 14 deletions(-) diff --git a/build/ci/integration-values.yaml b/build/ci/integration-values.yaml index cbdf7b6fd0..e8619f44c7 100644 --- a/build/ci/integration-values.yaml +++ b/build/ci/integration-values.yaml @@ -57,7 +57,7 @@ localSettings: DEBUG: true DOMAIN_LANGUAGE: {} APSCHEDULER_NAME: "apscheduler-{{ .Values.deployEnv }}" - SEARCH_ADMIN: "http://elasticsearch-data:9200" + SEARCH_URL: "http://elasticsearch-data:9200" TURN_SERVER: '' USE_CLOUDFLARE: false FRONT_END_URL: "http://${NAME}.integration.sefaria.org" diff --git a/build/ci/production-values.yaml b/build/ci/production-values.yaml index b653021544..f2bb659176 100644 --- a/build/ci/production-values.yaml +++ b/build/ci/production-values.yaml @@ -206,7 +206,7 @@ localSettings: } MONGO_HOST: "mongo" APSCHEDULER_NAME: "apscheduler-{{ .Values.deployEnv }}" - SEARCH_ADMIN: "http://elasticsearch-data:9200" + SEARCH_URL: "http://elasticsearch-data:9200" TURN_SERVER: '' USE_CLOUDFLARE: false FRONT_END_URL: "http://www.sefaria.org" diff --git a/build/ci/sandbox-values.yaml b/build/ci/sandbox-values.yaml index 776d232677..12dcce6766 100644 --- a/build/ci/sandbox-values.yaml +++ b/build/ci/sandbox-values.yaml @@ -53,7 +53,7 @@ localSettings: DEBUG: false DOMAIN_LANGUAGE: {} APSCHEDULER_NAME: "apscheduler-{{ .Values.deployEnv }}" - SEARCH_ADMIN: "http://elasticsearch-data:9200" + SEARCH_URL: "http://elasticsearch-data:9200" TURN_SERVER: '' USE_CLOUDFLARE: false FRONT_END_URL: "http://${NAME}.cauldron.sefaria.org" diff --git a/helm-chart/sefaria-project/templates/configmap/local-settings-file.yaml b/helm-chart/sefaria-project/templates/configmap/local-settings-file.yaml index 2fd02ba86d..860f93d95b 100644 --- a/helm-chart/sefaria-project/templates/configmap/local-settings-file.yaml +++ b/helm-chart/sefaria-project/templates/configmap/local-settings-file.yaml @@ -137,7 +137,7 @@ data: SERVER_EMAIL = os.getenv("SERVER_EMAIL") auth_str = f'{os.getenv("ELASTIC_USERNAME")}:{os.getenv("ELASTIC_PASSWORD")}@' if os.getenv("ELASTIC_USERNAME") else '' - SEARCH_ADMIN = f'http://{auth_str}' + {os.getenv("SEARCH_HOST")} + ":9200" + SEARCH_URL = f'http://{auth_str}' + {os.getenv("SEARCH_HOST")} + ":9200" SEARCH_INDEX_ON_SAVE = True SEARCH_INDEX_NAME_TEXT = 'text' # name of the ElasticSearch index to use SEARCH_INDEX_NAME_SHEET = 'sheet' diff --git a/helm-chart/sefaria-project/values.yaml b/helm-chart/sefaria-project/values.yaml index 7ba1f6af3f..a157d02918 100644 --- a/helm-chart/sefaria-project/values.yaml +++ b/helm-chart/sefaria-project/values.yaml @@ -329,9 +329,7 @@ secrets: # SEFARIA_DB: # SEFARIA_DB_USER: # SEFARIA_DB_PASSWORD: - # SEARCH_ADMIN_USER: - # SEARCH_ADMIN_PW: - # SEARCH_ADMIN_K8S: + # SEARCH_URL # TURN_SECRET: # TURN_USER: # SEFARIA_BOT_API_KEY: diff --git a/reader/views.py b/reader/views.py index 81c0878869..be9d24fb2a 100644 --- a/reader/views.py +++ b/reader/views.py @@ -48,7 +48,7 @@ from sefaria.utils.util import text_preview, short_to_long_lang_code, epoch_time from sefaria.utils.hebrew import hebrew_term, has_hebrew from sefaria.utils.calendars import get_all_calendar_items, get_todays_calendar_items, get_keyed_calendar_items, get_parasha, get_todays_parasha -from sefaria.settings import STATIC_URL, USE_VARNISH, USE_NODE, NODE_HOST, DOMAIN_LANGUAGES, MULTISERVER_ENABLED, SEARCH_ADMIN, MULTISERVER_REDIS_SERVER, \ +from sefaria.settings import STATIC_URL, USE_VARNISH, USE_NODE, NODE_HOST, DOMAIN_LANGUAGES, MULTISERVER_ENABLED, MULTISERVER_REDIS_SERVER, \ MULTISERVER_REDIS_PORT, MULTISERVER_REDIS_DB, DISABLE_AUTOCOMPLETER, ENABLE_LINKER from sefaria.site.site_settings import SITE_SETTINGS from sefaria.system.multiserver.coordinator import server_coordinator diff --git a/sefaria/helper/search.py b/sefaria/helper/search.py index 9dd542910e..757c931bfa 100644 --- a/sefaria/helper/search.py +++ b/sefaria/helper/search.py @@ -148,5 +148,5 @@ def make_filter(type, agg_type, agg_key): def get_elasticsearch_client(): from elasticsearch import Elasticsearch - from sefaria.settings import SEARCH_ADMIN - return Elasticsearch(SEARCH_ADMIN) + from sefaria.settings import SEARCH_URL + return Elasticsearch(SEARCH_URL) diff --git a/sefaria/local_settings_ci.py b/sefaria/local_settings_ci.py index de5d56d849..d542f0b58a 100644 --- a/sefaria/local_settings_ci.py +++ b/sefaria/local_settings_ci.py @@ -69,7 +69,7 @@ APSCHEDULER_NAME = "apscheduler" # ElasticSearch server -SEARCH_ADMIN = "http://localhost:9200" +SEARCH_URL = "http://localhost:9200" SEARCH_INDEX_ON_SAVE = False # Whether to send texts and source sheet to Search Host for indexing after save SEARCH_INDEX_NAME_TEXT = 'text' # name of the ElasticSearch index to use SEARCH_INDEX_NAME_SHEET = 'sheet' diff --git a/sefaria/local_settings_example.py b/sefaria/local_settings_example.py index 731ed44876..268f30366f 100644 --- a/sefaria/local_settings_example.py +++ b/sefaria/local_settings_example.py @@ -159,7 +159,7 @@ # URL to connect to ES server. # Set this to https://sefaria.org/api/search to connect to production search. # If ElasticSearch server has a password use the following format: http(s)://{username}:{password}@{base_url} -SEARCH_ADMIN = "http://localhost:9200" +SEARCH_URL = "http://localhost:9200" SEARCH_INDEX_ON_SAVE = False # Whether to send texts and source sheet to Search Host for indexing after save SEARCH_INDEX_NAME_TEXT = 'text' # name of the ElasticSearch index to use diff --git a/sefaria/search_ES6.py b/sefaria/search_ES6.py index fb0047e3af..812610eb07 100644 --- a/sefaria/search_ES6.py +++ b/sefaria/search_ES6.py @@ -33,12 +33,12 @@ from sefaria.system.database import db from sefaria.system.exceptions import InputError from sefaria.utils.util import strip_tags -from .settings import SEARCH_ADMIN, SEARCH_INDEX_NAME_TEXT, SEARCH_INDEX_NAME_SHEET, STATICFILES_DIRS +from .settings import SEARCH_URL, SEARCH_INDEX_NAME_TEXT, SEARCH_INDEX_NAME_SHEET, STATICFILES_DIRS from sefaria.site.site_settings import SITE_SETTINGS from sefaria.utils.hebrew import strip_cantillation import sefaria.model.queue as qu -es_client = Elasticsearch(SEARCH_ADMIN) +es_client = Elasticsearch(SEARCH_URL) index_client = IndicesClient(es_client) tracer = structlog.get_logger(__name__)