Skip to content

Store Collection metadata + component count in meilisearch - #684

Merged
rpenido merged 6 commits into
jill/collection-components-searchfrom
jill/reindex-collection
Sep 12, 2024
Merged

Store Collection metadata + component count in meilisearch#684
rpenido merged 6 commits into
jill/collection-components-searchfrom
jill/reindex-collection

Conversation

@pomegranited

@pomegranited pomegranited commented Sep 11, 2024

Copy link
Copy Markdown

Description

This PR makes several enhancements related to how Collections are indexed in the Studio Search app.

  1. Handles the LIBRARY_COLLECTION_CREATED / LIBRARY_COLLECTION_UPDATED events and adds/updates the collection document in the Studio content search index.
  2. Stores the Collection.key in the document block_id field. This key + the library_key is required for accessing the Collection REST APIs.
  3. Adds a new field to the document called num_children. Collections store the number of entities in the collection.
    Future PRs may store XBlock children counts here.

Libraries v2 is not used in production by default yet, so this change shouldn't affect any current users.

Supporting information

Related to openedx/frontend-app-authoring#1260
Based on openedx#35469
Private-ref: FAL-3787

Testing instructions

Set up tutor:

In the content-authoring MFE:

In the shell tutor dev run cms python manage.py cms shell, add blocks to the collection:

from opaque_keys.edx.keys import UsageKey
from opaque_keys.edx.locator import LibraryLocatorV2
from openedx.core.djangoapps.content_libraries import api                                                                                         
lib_key_str = "lib:SampleTaxonomyOrg1:AL1"
collection_key = "my-collection"
block_key_strs = [
    "lb:<your block key",
    "lb:<your block key",
    # ....
]

library_key = LibraryLocatorV2.from_string(lib_key_str)
block_keys = [
    UsageKey.from_string(key_str) for key_str in block_key_strs
]

api.update_library_collection_components(library_key, collection_key, usage_keys=block_keys)

In meilisearch http://meilisearch.local.edly.io:7700:

  • Login using the api key: tutor config printvalue MEILISEARCH_API_KEY
  • Search for your collection title and ensure you find it in the search index.
  • Check the following fields:
    id = collection.id (unique)
    block_id = collection.key
    num_children = <number of blocks in the collection>

Deadline

Before Sumac gets cut in October.

@rpenido rpenido left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good @pomegranited!
Some issues from openedx#35469 will also affect here, though.

Comment on lines +170 to +173
update_library_collection_index_doc.delay(
str(library_collection.library_key),
library_collection.collection_key,
)

@rpenido rpenido Sep 11, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make these events sync so the frontend is updated as soon as we make a change in the search index.

Suggested change
update_library_collection_index_doc.delay(
str(library_collection.library_key),
library_collection.collection_key,
)
api.upsert_library_collection_index_doc(library_collection.library_key, library_collection.collection_key)

A bit more context here: openedx#35367 (comment)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with 2c6c8cf.

Comment thread openedx/core/djangoapps/content/search/tasks.py

@rpenido rpenido left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @pomegranited 👍
Thank you for your work here!

@rpenido
rpenido merged commit 79f83d7 into jill/collection-components-search Sep 12, 2024
@rpenido
rpenido deleted the jill/reindex-collection branch September 12, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants