We are developping an opensource portal for education based on DjangoCMS and Elasticsearch (https://github.com/openfun/richie)
The catalog is composed of courses which each have course runs with dates, enrollment dates and languages.
The course is the main document and course runs are a nested field.
While searching through courses, I need to sort them by the status of their course runs (taking into account the applied filters, which can also filter on nested fields like enrollment dates or languages... tricky). Best is if a course has course runs open for enrollment, second best is if a course has course runs that are coming soon, etc. worse is if a course is past.
The situation changes everyday with time so we wrote a sorting script in
painless. This sorting script accesses course runs via the
Everything works fine but I read today that accessing the
_source field is very slow and should only be used in field scripts.
The code is opensource so if you know the intricacies of Elasticsearch, I would like to hear what you think and how it could be optimized!?
Painless script is still in a PR as of today and visible here: https://github.com/openfun/richie/blob/switch-to-indexing-courses-instead-of-course-runs/src/richie/apps/search/indexers/courses.py#L71