-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: meilisearch backend #150
Conversation
Thanks for the pull request, @qasimgulzar! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this PR make courseware search work using Meilisearch or just add a new "auto-suggest" search that works using Meilisearch? Or both?
edxsearch/settings.py
Outdated
@@ -26,7 +26,7 @@ | |||
# This is just a container for running tests | |||
DEBUG = True | |||
|
|||
ALLOWED_HOSTS = [] | |||
ALLOWED_HOSTS = ['*'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure when/if this settings
file is used, but I don't think we should just set ALLOWED_HOSTS = ['*']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is mostly used during development
edxsearch/settings.py
Outdated
################### Using Meilisearch (Beta) ################### | ||
|
||
# Enable Studio search features (powered by Meilisearch) (beta, off by default) | ||
MEILISEARCH_ENABLED = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it makes sense to have a setting called MEILISEARCH_ENABLED
. Instead, to enable Meilisearch, one would just set SEARCH_ENGINE
to the Meilisearch backend.
search/api.py
Outdated
|
||
def _meilisearch_auto_suggest_search_api(term, course_id, limit=30): | ||
""" | ||
Perform an auto-suggest search using the Elasticsearch search engine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perform an auto-suggest search using the Elasticsearch search engine. | |
Perform an auto-suggest search using the Meilisearch search engine. |
search/api.py
Outdated
|
||
def _meilisearch_auto_suggest_search_api(term, course_id, limit=30): | ||
""" | ||
Perform an auto-suggest search using the Elasticsearch search engine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is an "auto-suggest search"? How is it different than a regular search?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a POC for implementation I am going to remove it
search/api.py
Outdated
client = meilisearch.Client(settings.MEILISEARCH_URL, settings.MEILISEARCH_API_KEY) | ||
|
||
# Define the index name | ||
index_name = settings.MEILISEARCH_INDEX_PREFIX + "studio_content" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is searching the studio index. It doesn't make sense. It should get the index name from the subclass, and it definitely shouldn't be searching the studio content. For courseware search, it should be COURSEWARE_CONTENT_INDEX_NAME
search/meilisearch.py
Outdated
source["id"] = usage_key.block_id | ||
except (Exception, InvalidKeyError) as ex: # pylint: disable=broad-except | ||
source["id"] = sanitize_id(source["id"]) | ||
log.info(f"{str(ex)} - {source['id']} - {type(ex)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be covered by tests, and we don't need logging this verbose.
|
||
def sanitized_id(source: dict, create_usage_key=True) -> dict: | ||
""" | ||
Sanitize the Id key to avoid restricted objects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this function makes sense. Can you clarify what it's doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meilisearch doesn't allow to put course-key in ID attribute so to make it compatible I implemented this function.
return source | ||
|
||
|
||
def build_filter(key, val): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these functions will need extensive tests cases.
search/meilisearch.py
Outdated
@property | ||
def mappings(self): | ||
""" | ||
Get mapping of current index. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the "mappings" ?
search/meilisearch.py
Outdated
def __init__(self, index=None, options=None): | ||
super().__init__(index) | ||
MEILISEARCH_URL = getattr(settings, "MEILISEARCH_URL", 'http://127.0.0.1:7700') | ||
MEILISEARCH_API_KEY = getattr(settings, "MEILISEARCH_API_KEY", "masterKey") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if we should be putting the default values here - we might get inconsistent defaults if we just define the defaults separately in each place where we read the setting.
Your branch is behind the base. I've pulled in changes from master as a merge commit which will update your branch and cause the tests to be re-run. @qasimgulzar should you be listed under the Arbisoft entity CLA? Currently we have to run tests on your PR manually. |
Yes please if you can add me under arbisoft CLA that will be great. |
Yes, I confirm that @qasimgulzar is part of Arbisoft and should be added to the company CLA. Is there any step that we should pursue on our side? |
Hi @qasimgulzar! I see your CLA is all set. Do you plan to pursue this pull request? |
I am working on another extension but we might need this for further testing. |
Hi @e0d, I hope you are doing great. I will no longer be part of edly from 7, OCT 2024. could you please keep my CLA back to individual and remove me from arbisoft's CLA. |
Hi @qasimgulzar! Can this pull request be closed? |
closing this PR, as it is not intended to merged. |
Under this PR I have implemented a search backend for meilisearch.
Below is a screenshot of "discover now" page it is working with meilisearch backend.
Thread : https://discuss.openedx.org/t/is-meilisearch-a-viable-upgrade-alternative-to-opensearch/12400/12