Skip to content

fix: deduplicate search results when PST is re-imported#8

Merged
eSlider merged 4 commits intomasterfrom
fix/pst-reimport-search-duplicates
Feb 15, 2026
Merged

fix: deduplicate search results when PST is re-imported#8
eSlider merged 4 commits intomasterfrom
fix/pst-reimport-search-duplicates

Conversation

@eSlider
Copy link
Owner

@eSlider eSlider commented Feb 15, 2026

Closes #7

When a PST file is re-imported, each import creates a new account. SearchMulti was unioning all account indices without deduplication, so identical emails appeared multiple times in the search list.

Fix: Deduplicate in SearchMulti by content checksum extracted from the path format folder/{checksum}-{id}.eml. Uses DuckDB regexp_extract + ROW_NUMBER() OVER (PARTITION BY checksum ...) to keep one row per unique content across accounts.

Added TestSearchMultiDeduplicatesByChecksum to verify the behavior.

Made with Cursor

eSlider and others added 4 commits February 15, 2026 16:40
When the same PST file is imported multiple times, each import creates
a new account with duplicate emails. SearchMulti was unioning all
account indices without deduplication, so the same messages appeared
multiple times in the search list.

Fix: deduplicate in SearchMulti by content checksum (extracted from
path format folder/{checksum}-{id}.eml). Uses ROW_NUMBER() to keep one
row per unique content across accounts.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
regexp_extract returns empty string on no match; COALESCE('', x) yields ''
so all rows were partitioned by '' and collapsed to one. Use NULLIF to
treat empty as NULL so fallback to account||path keeps each row unique.

Co-authored-by: Cursor <cursoragent@cursor.com>
Paths from readpst (message_1.eml) lack checksum; account||path yielded
unique keys per account so same email in 2 accounts appeared twice.
Use subject|from|to|date|body as fallback fingerprint for dedup.

Co-authored-by: Cursor <cursoragent@cursor.com>
@eSlider eSlider merged commit 902b5c7 into master Feb 15, 2026
5 checks passed
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.

PST re-import: same messages appear multiple times in search

1 participant