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

[DONE] Patch elasticsearch options #1009

Merged
merged 3 commits into from
Dec 18, 2023
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
16 changes: 15 additions & 1 deletion pod/main/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -3122,6 +3122,20 @@
},
"pod_version_end": "",
"pod_version_init": "3.1.0"
},
"ES_OPTIONS": {
"default_value": {},
"description": {
"en": [
""
],
"fr": [
"Options d’ElasticSearch, notamment utilisées pour ES8 en SSL et avec un user en paramètre",
"Voir [https://www.elastic.co/guide/en/elasticsearch/client/python-api/current/config.html]() pour plus d'informations."
]
},
"pod_version_end": "",
"pod_version_init": "3.1.0"
}
},
"title": {
Expand Down Expand Up @@ -5069,4 +5083,4 @@
}
}
}
]
]
5 changes: 5 additions & 0 deletions pod/video_search/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ES_TIMEOUT = getattr(settings, "ES_TIMEOUT", 30)
ES_MAX_RETRIES = getattr(settings, "ES_MAX_RETRIES", 10)
ES_VERSION = getattr(settings, "ES_VERSION", 6)
ES_OPTIONS = getattr(settings, "ES_OPTIONS", {})


def index_es(video):
Expand All @@ -24,6 +25,7 @@ def index_es(video):
timeout=ES_TIMEOUT,
max_retries=ES_MAX_RETRIES,
retry_on_timeout=True,
**ES_OPTIONS,
)
if es.ping():
try:
Expand Down Expand Up @@ -57,6 +59,7 @@ def delete_es(video):
timeout=ES_TIMEOUT,
max_retries=ES_MAX_RETRIES,
retry_on_timeout=True,
**ES_OPTIONS,
)
if es.ping():
try:
Expand Down Expand Up @@ -88,6 +91,7 @@ def create_index_es():
timeout=ES_TIMEOUT,
max_retries=ES_MAX_RETRIES,
retry_on_timeout=True,
**ES_OPTIONS,
)
if ES_VERSION in [7, 8]:
template_file = "pod/video_search/search_template7.json"
Expand Down Expand Up @@ -117,6 +121,7 @@ def delete_index_es():
timeout=ES_TIMEOUT,
max_retries=ES_MAX_RETRIES,
retry_on_timeout=True,
**ES_OPTIONS,
)
try:
delete = es.indices.delete(index=ES_INDEX)
Expand Down
2 changes: 2 additions & 0 deletions pod/video_search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ES_TIMEOUT = getattr(settings, "ES_TIMEOUT", 30)
ES_MAX_RETRIES = getattr(settings, "ES_MAX_RETRIES", 10)
ES_VERSION = getattr(settings, "ES_VERSION", 6)
ES_OPTIONS = getattr(settings, "ES_OPTIONS", {})


def get_filter_search(selected_facets, start_date, end_date):
Expand Down Expand Up @@ -103,6 +104,7 @@ def search_videos(request):
timeout=ES_TIMEOUT,
max_retries=ES_MAX_RETRIES,
retry_on_timeout=True,
**ES_OPTIONS,
)
aggsAttrs = [
"owner_full_name",
Expand Down