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 #35026

Closed

Conversation

qasimgulzar
Copy link
Contributor

@qasimgulzar qasimgulzar commented Jun 24, 2024

Added meilisearch searcher backend class in edx-platform to support meilisearch integration.

Reason why I implemented inside edx-platform.

  • As per this ADR edx-search is going to be depreceated soon.
################### Studio/LMS Search (beta), using Meilisearch ###################

# Enable Studio search features (powered by Meilisearch) (beta, off by default)
MEILISEARCH_ENABLED = True
# Meilisearch URL that the python backend can use. Often points to another docker container or k8s service.
MEILISEARCH_URL = "http://meilisearch:7700"
# URL that browsers (end users) can use to reach Meilisearch. Should be HTTPS in production.
MEILISEARCH_PUBLIC_URL = "http://localhost:7700"
# To support multi-tenancy, you can prefix all indexes with a common key like "sandbox7-"
# and use a restricted tenant token in place of an API key, so that this Open edX instance
# can only use the index(es) that start with this prefix.
# See https://www.meilisearch.com/docs/learn/security/tenant_tokens
MEILISEARCH_INDEX_PREFIX = "meilisearch_"
MEILISEARCH_API_KEY = "masterKey"
SEARCH_ENGINE = "search.meilisearch.MeiliSearchEngine"

By using new meilisearch backend I have successfully managed to index exisitng elasticsearch compatibale indexes to meilisearch.

image

@openedx-webhooks
Copy link

openedx-webhooks commented Jun 24, 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/wg-maintenance-edx-platform. 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 24, 2024
@mphilbrick211
Copy link

Hi @qasimgulzar! Just flagging that there's a failing check here. Would you mind taking a look? Thanks!

@qasimgulzar qasimgulzar force-pushed the qasim/meilisearch-backend branch 2 times, most recently from 97702c5 to aefe51c Compare June 26, 2024 08:28
@qasimgulzar
Copy link
Contributor Author

qasimgulzar commented Jul 9, 2024

meilisearch is working with discover page
image

@qasimgulzar
Copy link
Contributor Author

image

In last commit I have fixed the facets listing for meilisearch backend

Copy link
Contributor

@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.

Can you please provide instructions for testing this PR?

I believe it depends on openedx/edx-search#150 for example, but this PR doesn't link to that one nor vice versa.

if hasattr(searcher, "backend_name") and searcher.backend_name == 'meilisearch':
result_ids = [result["id"] for result in response["results"]]
else:
result_ids = [result["data"]["id"] for result in response["results"]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the SearchEngine subclass in edx-search be transforming these results so that they're the same? I'd like to find a way to get rid of this if condition.

@@ -138,6 +141,9 @@ def index(cls, modulestore, structure_key, triggered_at=None, reindex_age=REINDE
if not searcher:
return

if hasattr(searcher, "update_settings"):
searcher.update_settings()
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. update_settings is not a clear name. I would prefer something like ensure_index_exists() or prepare_index()
  2. You should define and document this on the base class, so we can call it unconditionally here. Then it's part of the abstract API; but here it's just Meilisearch-specific code.

if hasattr(searcher, "backend_name") and searcher.backend_name == 'meilisearch':
result_ids = [result["id"] for result in response["results"]]
else:
result_ids = [result["data"]["id"] for result in response["results"]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment here - we should get rid of the if

@mphilbrick211 mphilbrick211 added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Jul 30, 2024
@mphilbrick211
Copy link

Hi @qasimgulzar! Just checking in to see if you are still planning to pursue this pull reqeust?

@qasimgulzar
Copy link
Contributor Author

No more required this PR, implementation os moved to openedx api

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 waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants