Skip to content
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

Closed
wants to merge 14 commits into from

Conversation

qasimgulzar
Copy link

@qasimgulzar qasimgulzar commented Jun 11, 2024

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.

image

Thread : https://discuss.openedx.org/t/is-meilisearch-a-viable-upgrade-alternative-to-opensearch/12400/12

@openedx-webhooks
Copy link

openedx-webhooks commented Jun 11, 2024

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If 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 @openedx/openedx-unmaintained. Tag them in a comment and let them know that your changes are ready for review.

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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jun 11, 2024
@qasimgulzar qasimgulzar marked this pull request as draft June 11, 2024 13:28
@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Jun 13, 2024
@qasimgulzar qasimgulzar marked this pull request as ready for review June 13, 2024 10:38
Copy link

@bradenmacdonald bradenmacdonald left a 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?

@@ -26,7 +26,7 @@
# This is just a container for running tests
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['*']

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 = ['*']

Copy link
Author

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

################### Using Meilisearch (Beta) ###################

# Enable Studio search features (powered by Meilisearch) (beta, off by default)
MEILISEARCH_ENABLED = False

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.

Choose a reason for hiding this comment

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

Suggested change
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.

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?

Copy link
Author

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"

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

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)}")

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

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?

Copy link
Author

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):

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.

@property
def mappings(self):
"""
Get mapping of current index.

Choose a reason for hiding this comment

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

What are the "mappings" ?

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")

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.

@qasimgulzar qasimgulzar changed the title feat: added new auto suggest endpoint. feat: meilisearch backend Jul 15, 2024
@e0d
Copy link

e0d commented Jul 24, 2024

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.

@mphilbrick211 mphilbrick211 removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Jul 24, 2024
@qasimgulzar
Copy link
Author

Yes please if you can add me under arbisoft CLA that will be great.

@regisb
Copy link
Contributor

regisb commented Jul 31, 2024

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?

@mphilbrick211
Copy link

Hi @qasimgulzar! I see your CLA is all set. Do you plan to pursue this pull request?

@qasimgulzar
Copy link
Author

qasimgulzar commented Aug 22, 2024

I am working on another extension but we might need this for further testing.

@qasimgulzar
Copy link
Author

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.

@mphilbrick211
Copy link

Hi @qasimgulzar! Can this pull request be closed?

@qasimgulzar
Copy link
Author

closing this PR, as it is not intended to merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants