Fix search result rendering for returned matches#366
Merged
Conversation
Reviewer's GuideThis PR tightens search result relevance and ensures search results render even when their views are not present in the current outline by adding a score threshold to search APIs, lazily loading missing view metadata on the client, and extending tests to cover these flows. Sequence diagram for search workspace APIs with score thresholdsequenceDiagram
actor User
participant BestMatch
participant miscApi
participant SearchAPI
User->>BestMatch: type in search query
BestMatch->>miscApi: searchWorkspaceDocuments(workspaceId, query)
miscApi->>SearchAPI: GET /api/search/{workspaceId}
activate SearchAPI
Note right of miscApi: params: query, limit, preview_size,
Note right of miscApi: score = SEARCH_SCORE_THRESHOLD (0.2)
SearchAPI-->>miscApi: APIResponse<SearchDocumentResponseItem[]>
deactivate SearchAPI
miscApi-->>BestMatch: SearchDocumentResponseItem[]
BestMatch->>miscApi: searchWorkspaceDocumentPage(workspaceId, query, offset)
miscApi->>SearchAPI: GET /api/search/{workspaceId}/documents
activate SearchAPI
Note right of miscApi: params include score = SEARCH_SCORE_THRESHOLD (0.2)
SearchAPI-->>miscApi: APIResponse<SearchDocumentResponsePage>
deactivate SearchAPI
miscApi-->>BestMatch: SearchDocumentResponsePage
Sequence diagram for lazy loading missing search result viewssequenceDiagram
participant BestMatch
participant ViewService
BestMatch->>BestMatch: handleSearch(query)
BestMatch->>BestMatch: mergeSearchResults([], page.items)
BestMatch->>BestMatch: buildSearchItems(results)
activate BestMatch
BestMatch->>BestMatch: resolveSearchResultView(outline, item*)
alt view found in outline
BestMatch-->>BestMatch: use existing view
else view missing from outline
BestMatch->>BestMatch: getSearchResultViewIdCandidates(item)
loop candidates viewId
BestMatch->>ViewService: get(workspaceId, viewId)
alt ViewService.get succeeds
ViewService-->>BestMatch: View
BestMatch-->>BestMatch: break loop
else ViewService.get throws
ViewService-->>BestMatch: error
end
end
end
BestMatch-->>BestMatch: items: SearchViewListItem[]
BestMatch->>BestMatch: [searchSeqRef.current !== searchSeq]
alt sequence changed
BestMatch-->>BestMatch: abort using searchItems
else sequence unchanged
BestMatch-->>BestMatch: setItems(searchItems)
end
deactivate BestMatch
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Tests
Summary by Sourcery
Improve search result handling by filtering low-score matches and loading missing view metadata for search results.
Bug Fixes:
Enhancements:
Build:
Tests: