fetchkit: refine ranking and snippet results#12
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b548baad89
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let snippetText = truncatedSnippetText( | ||
| from: text, | ||
| bounds: snippetBounds | ||
| ) | ||
| let matchRanges = matches.compactMap { snippetRange(for: $0, within: snippetBounds, in: text) } |
There was a problem hiding this comment.
Keep snippet match ranges aligned with emitted text
buildSnippet computes matchRanges from raw snippetBounds, but the emitted snippetText is produced by truncatedSnippetText, which trims whitespace and can prepend/append …. Because the ranges are not adjusted after those edits, any cropped snippet can return offsets that no longer point at the matched terms in FetchSnippet.text, causing incorrect or missing highlights in consumers that trust matchRanges.
Useful? React with 👍 / 👎.
| let phrase = FetchSearchSupport.exactPhraseText(from: query) | ||
| guard !phrase.isEmpty, lowercaseText.range(of: phrase) != nil else { |
There was a problem hiding this comment.
Preserve exact-phrase behavior across index backends
The in-memory path now strips quotes before exact-phrase matching, so a query like "bright apple" can match there, but the SearchKit backend still wraps the raw query text in quotes (SearchKitFetchIndex.searchString(for:kind:)), which makes quoted input a literal-quote phrase query. This introduces backend-dependent behavior for the same FetchSearchQuery input and can silently drop results when callers include quotes in .exactPhrase searches.
Useful? React with 👍 / 👎.
Summary
Verification