♻️(search) migrate to opensearch-py Q-types#130
Closed
StephanMeijer wants to merge 2 commits into
Closed
Conversation
feef2af to
a7128b9
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the backend OpenSearch query-building layer to use opensearch-py Q objects (instead of raw dicts), adds a small sort DSL wrapper, and introduces a broad set of unit/integration tests to lock in access-control and query-shape behavior.
Changes:
- Migrated search query construction (
get_filter,get_query,get_full_text_query) toopensearchpy.Qand introducedSortSpecfor sort clause generation. - Updated the document deletion query builder to use
Qobjects and serialize via.to_dict(). - Added extensive unit + API integration test coverage for query building, access control, filtering, sorting, and deletion behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/backend/core/services/search.py |
Rebuilds search/filter/query/sort composition using opensearchpy.Q and SortSpec, serializing to dict at request time. |
src/backend/core/views.py |
Updates deletion query construction to build with Q objects and serialize to dict for OpenSearch. |
src/backend/core/tests/test_search.py |
Adds a large unit test suite for query building, access control filtering, and sort spec behavior. |
src/backend/core/tests/test_api_search.py |
Adds integration tests for the search API endpoint (auth, filtering, sorting, access control). |
src/backend/core/tests/test_api_documents_delete.py |
Adds deletion-query unit tests alongside existing deletion endpoint integration tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
53d8977 to
bc91921
Compare
c52cb70 to
b8227f0
Compare
Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
147ae1c to
0aad4f5
Compare
Collaborator
Author
|
Important Moved to #139 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Please merge first: #129, #127, #126, #125, #124, #123, #138
Important
Moved to #139
Summary
search.pyto use Q objects from opensearch-py for type-safe query buildingSortSpecdataclass for DSL-like sort clause constructiontyping.Anyusage in favor of proper typesChanges
src/backend/core/services/search.pysrc/backend/core/views.pysrc/backend/core/tests/test_search.pysrc/backend/core/tests/test_api_search.pysrc/backend/core/tests/test_api_documents_delete.pyVerification