#6027 - Exhaustive conversation search #6078
Open
+452
−18
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.
First time contributor checklist
Contributor checklist
*iPhone 16 Pro, iOS 18.5
Description
This pull request fixes #6027 by making conversation search truly exhaustive. Originally, searching within a conversation would perform a global FTS search across all conversations (limited to 500 results), then filter by thread ID at the application level.
Problem
A conversation search that looks like:
This was impossible since "https" is more specific than "http", indicating the search was not exhaustive.
Root Cause
The original flow was:
SELECT * FROM fts_table WHERE content MATCH 'https' LIMIT 500
message.uniqueThreadId == targetThreadId
If most of the 500 global matches were from other conversations, the target conversation would get incomplete results.
Solution
Move the thread filtering to the database level using SQL JOINs:
Now the LIMIT applies only to messages within the target conversation, ensuring exhaustive results.
Changes Made
Enhanced
FullTextSearchIndexer.swift
search()
method with optionalthreadUniqueId
parameterthreadUniqueId
is provided, uses thread-specific SQL query with JOINUpdated
FullTextSearcher.swift
searchWithinConversation()
now uses the new thread-specific search methodAdded comprehensive tests
FullTextSearchIndexerTest.swift
which covers: