Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions apps/web/app/api/search/hybrid/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,31 @@ export async function POST(request: Request) {
return Response.json({ posts: [] })
}

if (type === "text") {
const textResults = await searchPostsText(query, owner, repo, {
perPage: 20,
categoryId,
})
const textPosts = await enrichPosts(textResults, owner, repo)
return Response.json({ posts: textPosts })
}
try {
if (type === "text") {
const textResults = await searchPostsText(query, owner, repo, {
perPage: 20,
categoryId,
})
const textPosts = await enrichPosts(textResults, owner, repo)
return Response.json({ posts: textPosts })
}

if (type === "semantic") {
const semanticResults = await searchPostsSemantic(query, owner, repo, {
perPage: 5,
categoryId,
})
const semanticPosts = await enrichPosts(semanticResults, owner, repo)
return Response.json({ posts: semanticPosts })
}
if (type === "semantic") {
const semanticResults = await searchPostsSemantic(query, owner, repo, {
perPage: 5,
categoryId,
})
const semanticPosts = await enrichPosts(semanticResults, owner, repo)
return Response.json({ posts: semanticPosts })
}

return Response.json({ posts: [] })
return Response.json({ posts: [] })
} catch (error) {
console.error("Hybrid search error:", error)
return Response.json(
{ posts: [], error: "Search failed" },
{ status: 500 }
)
}
}