feat: search the catalog by meaning - #640
Draft
jaspermayone wants to merge 1 commit into
Draft
jaspermayone wants to merge 1 commit into
jaspermayone wants to merge 1 commit into
Conversation
Adds semantic=true to the sections and instructors endpoints, on REST and on GraphQL. The query is embedded once and cached, the vectors rank whatever the other filters left, and a failure falls back to the keyword search rather than erroring. The semantic_search flag gates the cost. Without it, or without OPENAI_API_KEY, the catalog answers exactly as it does today.
jaspermayone
added this pull request to stack #643
September 19, 2026 22:17
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.
Part of #453. Stacked on #639.
qmatches the literal words.semantic=trueranks by meaning instead, so"intro to programming" reaches "Computer Science I". It works on sections and
on instructors, on REST and on GraphQL.
curl "…/api/v1/catalog/sections?q=learn+to+program&semantic=true&term_uid=202710"{ sections(filter: { q: "learn to program", semantic: true }, first: 10) { nodes { crn title } } }How a request runs
flowchart TD A["q + semantic=true"] --> B{Flag on and<br/>OPENAI_API_KEY set?} B -->|no| K[Keyword search] B -->|yes| C{Query in the cache?} C -->|yes| E[Rank the filtered rows<br/>by cosine distance] C -->|no| D[Embed the query] D -->|API failed| K D -->|vector| E E --> F[One page, nearest first]Points worth reviewing:
leaves the page short.
same few things during registration week.
returns an error because the API was down.
semantic_searchis a global Flipper flag. Turning it off stops everyembedding call at once.
keyword search keeps its 300/min.
Docs and the OpenAPI document are updated.
Tests
bundle exec rspecis green locally (1531 examples), including the fallbackpaths, the cache, and both API surfaces.
Stack created with GitHub Stacks CLI • Give Feedback 💬