Skip to content

Commit d7503c6

Browse files
committed
fixup! feat: Adds a way to find the difference in Meiliseach state and come up with a migration plan and configuration plan depending on the state. This introduces a mechanism it or a drift engine which drill down the Meiliseach configuration and figures out what has changed:
1 parent 8442993 commit d7503c6

1 file changed

Lines changed: 5 additions & 29 deletions

File tree

  • openedx/core/djangoapps/content/search

openedx/core/djangoapps/content/search/api.py

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -350,32 +350,6 @@ def reset_index(status_cb: Callable[[str], None] | None = None) -> None:
350350
status_cb("Index reset complete.")
351351

352352

353-
def _is_index_configured(index_name: str) -> bool:
354-
"""
355-
Check if an index is completely configured
356-
357-
Args:
358-
index_name (str): The name of the index to check
359-
"""
360-
client = _get_meilisearch_client()
361-
index = client.get_index(index_name)
362-
index_settings = index.get_settings()
363-
for k, v in (
364-
("distinctAttribute", INDEX_DISTINCT_ATTRIBUTE),
365-
("filterableAttributes", INDEX_FILTERABLE_ATTRIBUTES),
366-
("searchableAttributes", INDEX_SEARCHABLE_ATTRIBUTES),
367-
("sortableAttributes", INDEX_SORTABLE_ATTRIBUTES),
368-
("rankingRules", INDEX_RANKING_RULES),
369-
):
370-
setting = index_settings.get(k, [])
371-
if isinstance(v, list):
372-
v = set(v)
373-
setting = set(setting)
374-
if setting != v:
375-
return False
376-
return True
377-
378-
379353
@define
380354
class IndexDrift:
381355
"""
@@ -410,8 +384,7 @@ def _detect_index_drift(index_name: str) -> IndexDrift:
410384
"""
411385
Inspect the current state of a Meilisearch index and return a structured drift report.
412386
413-
This is a richer alternative to _is_index_configured() that provides per-setting
414-
match status plus primary key and emptiness information.
387+
It provides per-setting match status plus primary key and emptiness information.
415388
416389
Args:
417390
index_name (str): The name of the index to inspect.
@@ -546,7 +519,7 @@ def reconcile_index(
546519
)
547520
return
548521

549-
# CASE: Index populated
522+
# CASE: Index populated, attribute drifted i.e settings mismatched
550523
if drift.is_settings_drifted:
551524
warn_cb(f"Settings drift detected on populated index '{STUDIO_INDEX_NAME}'. Applying updated settings...")
552525
# Log per-setting mismatch details
@@ -572,10 +545,13 @@ def reconcile_index(
572545

573546
def init_index(status_cb: Callable[[str], None] | None = None, warn_cb: Callable[[str], None] | None = None) -> None:
574547
"""
548+
This method is depricated as of Verawood and would be removed in the future release.
549+
575550
Initialize the Meilisearch index, creating it and configuring it if it doesn't exist.
576551
577552
This is a compatibility wrapper around reconcile_index().
578553
"""
554+
log.warning("init_index is deprecated as of Verawood and will be removed in the future release.")
579555
reconcile_index(status_cb=status_cb, warn_cb=warn_cb)
580556

581557

0 commit comments

Comments
 (0)