-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add source-type filter to search (#246) #268
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,6 +142,7 @@ export async function handleRequest( | |
| return; | ||
| } | ||
| const topic = url.searchParams.get("topic") ?? undefined; | ||
| const source = url.searchParams.get("source") ?? undefined; | ||
| const tag = url.searchParams.get("tag") ?? undefined; | ||
| const limitRaw = url.searchParams.get("limit"); | ||
| const limitParsed = limitRaw ? parseInt(limitRaw, 10) : NaN; | ||
|
|
@@ -151,7 +152,14 @@ export async function handleRequest( | |
| const offset = Number.isNaN(offsetParsed) ? undefined : offsetParsed; | ||
| const tags = tag ? [tag] : undefined; | ||
|
|
||
| const result = await searchDocuments(db, provider, { query: q, topic, tags, limit, offset }); | ||
| const result = await searchDocuments(db, provider, { | ||
| query: q, | ||
| topic, | ||
| tags, | ||
| source, | ||
| limit, | ||
| offset, | ||
| }); | ||
|
Comment on lines
+155
to
+162
|
||
| const took = Math.round(performance.now() - start); | ||
| sendJson(res, 200, result, took); | ||
| return; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sourceis accepted as an arbitrary string and forwarded tosearchDocuments, but the DB constrainsdocuments.source_typeto a small set of values (library,topic,manual,model-generated). For invalid values, the API will silently return 0 results, which is hard to diagnose. Consider validatingsourceagainst the allowed set and returning a 400 VALIDATION_ERROR with a clear message when it’s not recognized.