Skip to content

Dedupe blog search results so a post appears only once - #8081

Merged
nurul3101 merged 1 commit into
mainfrom
fix/blog-search-duplicate-results
Jul 17, 2026
Merged

Dedupe blog search results so a post appears only once#8081
nurul3101 merged 1 commit into
mainfrom
fix/blog-search-duplicate-results

Conversation

@nurul3101

@nurul3101 nurul3101 commented Jul 17, 2026

Copy link
Copy Markdown
Member

Problem

Searching the blog shows the same post multiple times. For example, searching "Neon" returns Prisma Postgres vs Neon Pricing 2026 four times:

The blog search is backed by a Mixedbread vector store, which searches at the chunk level. The route's transform mapped every matching chunk to its own page result (keyed by file_id-chunk_index), so any post matching the query in several chunks rendered as several identical cards. Live evidence: /blog/api/search?query=Neon returned the same file_id with chunk indices 0, 1, 2, and 3 as four separate results.

The more relevant a post is to a query, the more chunks match, and the more it duplicates. The duplicates also crowd out other posts inside the topK: 20 window.

Fix

Track seen file_ids in the transform and skip chunks from files already emitted. Results arrive in score order, so each post keeps its best-ranked position and appears exactly once. Query-time only, no reindexing of the store needed.

Verification

No MIXEDBREAD_API_KEY is available locally, so I replayed the exact live chunk sequence for "Neon" (4 chunks of the pricing post interleaved with 2 other posts) through the real route GET handler with only the SDK network call stubbed:

  • Before: 7 results, pricing post duplicated 4 times (reproduces production behavior)
  • After: 3 results, one per post, pricing post still ranked first

types:check (tsc) passes; oxlint reports 0 errors.

Summary by CodeRabbit

  • Bug Fixes
    • Search results now show only one result per file or blog post.
    • Removed duplicate entries caused by multiple matches within the same file.

Mixedbread returns chunk-level matches, and the search route mapped every
chunk to its own page result. A post matching a query in several chunks
(e.g. "Neon" for the Neon pricing post) showed up 2-4 times in the search
dialog. Keep only the first (highest-scoring) chunk per file_id; this also
frees up topK slots for more distinct posts.
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blog Ready Ready Preview, Comment Jul 17, 2026 11:48am
docs Ready Ready Preview, Comment Jul 17, 2026 11:48am
eclipse Ready Ready Preview, Comment Jul 17, 2026 11:48am
site Ready Ready Preview, Comment Jul 17, 2026 11:48am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e43849e2-260a-4a90-95f7-80ada5df31c5

📥 Commits

Reviewing files that changed from the base of the PR and between 3b39d56 and 2ceb489.

📒 Files selected for processing (1)
  • apps/blog/src/app/api/search/route.ts

Walkthrough

Changes

Blog search deduplication

Layer / File(s) Summary
Filter duplicate file matches
apps/blog/src/app/api/search/route.ts
The search transformer tracks seen file_id values and excludes later chunk matches from the same file.

Estimated code review effort: 2 (Simple) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: deduplicating blog search results so each post appears once.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@argos-ci

argos-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jul 17, 2026, 11:55 AM

@nurul3101

Copy link
Copy Markdown
Member Author

@coderabbitai approve

@nurul3101
nurul3101 merged commit 97ede65 into main Jul 17, 2026
17 checks passed
@nurul3101
nurul3101 deleted the fix/blog-search-duplicate-results branch July 17, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants