Hybrid Search: Fix "resource type" filter#3528
Merged
Merged
Conversation
OpenAPI Changes3 changes: 0 error, 0 warning, 3 info Unexpected changes? Ensure your branch is up-to-date with |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes hybrid/vector search filtering for the “resource category” facet by wiring the resource_category filter through the backend request serializer/OpenAPI spec and through the frontend vector-search request construction, with regression tests added on both sides.
Changes:
- Add
resource_categoryto the vector-search filter serializer so it’s forwarded into Qdrant filter conditions. - Update OpenAPI specs and regenerated TS API clients (v0 + v1) to include the new query parameter.
- Update frontend hybrid search param mapping and add a SearchPage regression test to ensure
resource_categoryis sent to the vector endpoint.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vector_search/serializers.py | Adds resource_category to shared Qdrant-backed filter serializer. |
| vector_search/serializers_test.py | Tests serializer acceptance + inheritance of resource_category. |
| vector_search/views_test.py | Ensures Qdrant query/scroll filters include resource_category. |
| openapi/specs/v1.yaml | Documents resource_category query param for relevant v1 endpoints. |
| openapi/specs/v0.yaml | Documents resource_category query param for relevant v0 endpoint. |
| frontends/main/src/page-components/SearchDisplay/HybridSearchDisplay.tsx | Passes resource_category into vector-search request params. |
| frontends/main/src/app-pages/SearchPage/SearchPage.test.tsx | Adds regression test asserting resource_category is included in vector-search request URL. |
| frontends/api/src/generated/v1/api.ts | Regenerated client: includes resource_category on v1 requests. |
| frontends/api/src/generated/v0/api.ts | Regenerated client: includes resource_category on v0 requests. |
Comment on lines
+88
to
+96
| const getLastVectorApiSearchParams = () => { | ||
| const call = makeRequest.mock.calls.find(([args]) => { | ||
| if (args.method !== "get") return false | ||
| return args.url.startsWith(urls.search.vectorResources()) | ||
| }) | ||
| invariant(call) | ||
| const fullUrl = new URL(call[0].url, "http://mit.edu") | ||
| return fullUrl.searchParams | ||
| } |
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.
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/11858
Description (What does it do?)
This PR resolves an issue where in the hybrid search interface (topic pages which is live) the "resource category" filter does not work when looking at learning materials.
Screenshots (if appropriate):
How can this be tested?
./manage.py generate_embeddings --videos --video_playlists --documents --podcasts --skip-contentfiles