edx-search
raw JSON → 5.0.0 verified Fri May 01 auth: no python
Search and indexing routines for Open edX, supporting Elasticsearch, Meilisearch, and Typesense backends. Current version 5.0.0 as of August 2024. Release cadence is roughly quarterly.
pip install edx-search Common errors
error ImportError: cannot import name 'SearchEngine' from 'search' ↓
cause Top-level 'search' package does not export SearchEngine directly.
fix
Use: from search.search_engine_base import SearchEngine
error TypeError: Engine.__init__() got an unexpected keyword argument 'api_key' ↓
cause Elasticsearch backend does not accept 'api_key' as a keyword, but Meilisearch does.
fix
Remove 'api_key' for Elasticsearch or use 'cloud_id' and 'http_auth' for Elasticsearch 8.x.
error AttributeError: 'Elasticsearch' object has no attribute 'delete_by_query' ↓
cause Elasticsearch 8.x client changed API methods.
Warnings
breaking Version 5.0.0 introduces a new Typesense backend and drops Python 3.11 support (now requires Python 3.12+). Code using Django <4.2 may break. ↓
fix Upgrade Python to 3.12+ and update Django to >=4.2.
breaking Version 4.0.0 dropped Python 3.8 support and switched from Elasticsearch 7.x to 8.x. Connection code using old library API will fail. ↓
fix Update Elasticsearch client to 8.x and adjust import paths (e.g., elasticsearch8).
deprecated The 'catalog_visibility' filter in courseware_content was added in 4.1.2; earlier versions ignore it silently. ↓
fix Upgrade to 4.1.2+ to use this filter.
gotcha Search engine initialization requires explicitly passing backend-specific kwargs (url, api_key). Omitting them defaults to Elasticsearch at localhost:9200 (no auth), which may not exist. ↓
fix Always provide 'url' and 'api_key' matching your backend.
Imports
- SearchEngine wrong
from search import SearchEnginecorrectfrom search.search_engine_base import SearchEngine
Quickstart
from search.search_engine_base import SearchEngine
engine = SearchEngine(index_name='my_index', url='http://localhost:7700', api_key=os.environ.get('MEILI_API_KEY', ''))