Skip to content

[FC-0144] Python search API with text, paging and exact filters - #34

Merged
bradenmacdonald merged 7 commits into
openedx:mainfrom
open-craft:feat/python-filter-query
Dec 5, 2026
Merged

bradenmacdonald merged 7 commits into
openedx:mainfrom
open-craft:feat/python-filter-query

Conversation

@navinkarkera

@navinkarkera navinkarkera commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Adds a Python search API for maintenance tasks: a SearchQuery with text, exact-match filters and paging, exposed through api.search, with filter fields validated against the schema. No frontend changes.

Diff: open-craft/openedx-search@rpenido/FAL-4404/upsert-delete-api...feat/python-filter-query

Based on #32 (per review) so it can merge once the base functions land. The Meilisearch adapter lives in #33, so the Meilisearch search() implementation and its tests are NOT in this PR - they're on the feat/python-filter-query-meilisearch branch, stacked on #33, where the feature was tested live on dev Tutor with Meilisearch. This PR is tested via the fake adapter.

Closes #9

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Nov 25, 2026
@openedx-webhooks

openedx-webhooks commented Nov 25, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @navinkarkera!

This repository is currently maintained by @ormsbee.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are 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.

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

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Nov 25, 2026
@navinkarkera
navinkarkera force-pushed the feat/python-filter-query branch from a3f5153 to f545a55 Compare November 25, 2026 17:09
@navinkarkera navinkarkera changed the title Add a Python search API for maintenance tasks Python search API with text, paging and exact filters Nov 27, 2026

@rpenido rpenido left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍
Thank you for your work, @navinkarkera!

  • I tested this using the instructions from the PR
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

Left a NIT and a comment.

Note: I think it would be better to base it on #32 instead of #33, so we can merge it earlier.
I will probably have #33 after all the base functions (which may also include #40)

Comment thread src/openedx_search/adapters.py Resolved
Comment thread src/openedx_search/adapters.py Resolved
@navinkarkera
navinkarkera force-pushed the feat/python-filter-query branch from cf4d5c9 to a944a4b Compare November 27, 2026 15:22
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Dec 2, 2026
@navinkarkera
navinkarkera force-pushed the feat/python-filter-query branch from a944a4b to 706080d Compare December 3, 2026 09:19
@navinkarkera

navinkarkera commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

@rpenido

I've rebased onto #32 as you suggested, so this PR now has just the library-side search API - SearchQuery, api.search and the filter validation, all tested with the fake adapter.

One heads-up: the Meilisearch code had to move out. The adapter doesn't exist on #32, so search() for Meilisearch and its tests didn't fit. They're on a new branch now - feat/python-filter-query-meilisearch, the same commits stacked on your #33 head, including the fixes to work with your check_writes() batch logic.

So this PR is fake-tested only; the live Meilisearch testing I did applies to that branch. Feel free to fold those commits into #33 when it lands, or I can open a PR from it - whatever works best for you.

@rpenido

rpenido commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Thanks @navinkarkera!
Can you check the comments I left in the review?
Also, for the PR, we need to update the body. A link to the diff (there was one before) would be helpful. Also, remove the "Typesense remains covered by unit tests only." part.

Edit: Can you also add "[FC-0144]" to the title, and "Closes #9" so it links to the issue?

@navinkarkera navinkarkera changed the title Python search API with text, paging and exact filters [FC-0144] Python search API with text, paging and exact filters Dec 4, 2026
@navinkarkera

Copy link
Copy Markdown
Contributor Author

@rpenido Thanks! update the pr description as well as title. I think all review comments are addressed now.

SearchQuery carries the text, one bounded page and the same exact filter expression delete() accepts, including id equality and IN lists. api.search() resolves the registration and delegates to Adapter.search(), which the Meilisearch adapter implements against the live index with q, offset, limit and the rendered filter. count_only sends limit 0 so the migrator can count without transferring a page; the estimated total is never reported as exact.
The shared hit count validation it also carried belongs to the
Meilisearch adapter branch.
@rpenido
rpenido force-pushed the feat/python-filter-query branch from 7b83eaf to 54fe7ca Compare December 4, 2026 21:29
@bradenmacdonald
bradenmacdonald marked this pull request as ready for review December 4, 2026 21:32

@bradenmacdonald bradenmacdonald left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good. Just two nits.

Comment thread docs/how-tos/registering-use-cases.rst Outdated
for ``api.search()``, in addition to the ``settings.get`` the adapter already
needs to reconcile settings and to check the page limit. ``search_api_key``
stays optional and unrelated to these calls: it is the parent key for scoped
tenant credentials.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could be useful to mention

Typesense requires it: the parent of a scoped key must
allow only documents:search, so the write key (api_key) cannot mint one.

here too. Just because it's not clear and the reader may have missed it in the ADR 002.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! Fixed here: 4be4377

Comment thread src/openedx_search/adapters.py Outdated
Comment on lines +256 to +258
(``id IN [x, y, z]``). Whether ``total`` is exact is an engine property,
reported in ``SearchResult.total_is_exact``. It is never assumed from a
successful request.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: this data structure is for the request, not the response, so why is the docstring describing the total field in the response?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done! Updated here: 4be4377

@bradenmacdonald
bradenmacdonald enabled auto-merge (squash) December 4, 2026 23:16
@bradenmacdonald

Copy link
Copy Markdown

I'm going to close and re-open to see if that triggers the CLA check to work.

auto-merge was automatically disabled December 5, 2026 00:19

Pull request was closed

@github-project-automation github-project-automation Bot moved this from Waiting on Author to Done in Contributions Dec 5, 2026
@bradenmacdonald
bradenmacdonald merged commit e057be9 into openedx:main Dec 5, 2026
18 checks passed
@bradenmacdonald
bradenmacdonald deleted the feat/python-filter-query branch December 5, 2026 00:20
@bradenmacdonald bradenmacdonald added the FC Relates to an Axim Funded Contribution project label Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Python query API with minimal filter support (e.g. 'ID = x' or 'ID in [x, y, z]')

4 participants