Skip to content

Commit

Permalink
[DONE] Patch elasticsearch options (#1009)
Browse files Browse the repository at this point in the history
* Update configuration.json

* Update views.py

* Update utils.py
  • Loading branch information
CartierPierre authored Dec 18, 2023
1 parent 1d788ce commit 335481f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
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

0 comments on commit 335481f

Please sign in to comment.