From 5be8e621e15f0c191c52270f1fa6ecbbe51c0ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Thu, 17 Oct 2024 23:54:15 +0200 Subject: [PATCH] feat: migrate to Meilisearch We make use of a new search engine to search annotations. The index will automatically be created and filled during init. This is considered a breaking change if you have customised your notes index. --- changelog.d/20241017_233457_regis_meilisearch.md | 1 + tutornotes/templates/notes/apps/settings/tutor.py | 11 ++++++----- tutornotes/templates/notes/build/notes/Dockerfile | 6 ++++++ tutornotes/templates/notes/tasks/notes/init | 4 +++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/changelog.d/20241017_233457_regis_meilisearch.md b/changelog.d/20241017_233457_regis_meilisearch.md index e21cac3..33808d4 100644 --- a/changelog.d/20241017_233457_regis_meilisearch.md +++ b/changelog.d/20241017_233457_regis_meilisearch.md @@ -1 +1,2 @@ - [Bugfix] Actually mount edx-notes-api repositories from host on `tutor mounts add /path/to/edx-notes-api`. (by @regisb) +- 💥[Feature] Replace Elasticsearch by Meilisearch. The implementation is much more compact and readable. All content will be automatically re-indexed during init. (by @regisb) diff --git a/tutornotes/templates/notes/apps/settings/tutor.py b/tutornotes/templates/notes/apps/settings/tutor.py index 35b0b34..be75dd4 100644 --- a/tutornotes/templates/notes/apps/settings/tutor.py +++ b/tutornotes/templates/notes/apps/settings/tutor.py @@ -23,11 +23,12 @@ CLIENT_ID = "notes" CLIENT_SECRET = "{{ NOTES_OAUTH2_SECRET }}" -ELASTICSEARCH_DSL = { - 'default': { - 'hosts': '{{ ELASTICSEARCH_SCHEME }}://{{ ELASTICSEARCH_HOST }}:{{ ELASTICSEARCH_PORT }}' - } -} +# Meilisearch credentials +ES_DISABLED = True +MEILISEARCH_ENABLED = True +MEILISEARCH_URL = "{{ MEILISEARCH_URL }}" +MEILISEARCH_API_KEY = "{{ MEILISEARCH_API_KEY }}" +MEILISEARCH_INDEX = "{{ MEILISEARCH_INDEX_PREFIX }}student_notes" LOGGING = { "version": 1, diff --git a/tutornotes/templates/notes/build/notes/Dockerfile b/tutornotes/templates/notes/build/notes/Dockerfile index 7bd90db..bd7d025 100644 --- a/tutornotes/templates/notes/build/notes/Dockerfile +++ b/tutornotes/templates/notes/build/notes/Dockerfile @@ -28,6 +28,12 @@ USER ${APP_USER_ID} RUN git clone {{ NOTES_REPOSITORY }} --branch {{ NOTES_REPOSITORY_VERSION }} --depth 1 /app/edx-notes-api WORKDIR /app/edx-notes-api +# TODO remove after PR is merged +# https://github.com/openedx/edx-notes-api/pull/444 +RUN git remote add regisb https://github.com/regisb/edx-notes-api \ + && git fetch regisb regisb/meilisearch \ + && git merge regisb/regisb/meilisearch + ###### Install python venv ###### RUN python -m venv /app/venv ENV PATH=/app/venv/bin:${PATH} diff --git a/tutornotes/templates/notes/tasks/notes/init b/tutornotes/templates/notes/tasks/notes/init index b0f3606..4d12a18 100644 --- a/tutornotes/templates/notes/tasks/notes/init +++ b/tutornotes/templates/notes/tasks/notes/init @@ -1,2 +1,4 @@ ./manage.py migrate -./manage.py search_index --rebuild -f + +# Re-index with meilisearch +./manage.py shell -c "from notesapi.v1.views.meilisearch import reindex; reindex()"