Repository navigation
Add token-based matching to improve search recall for non-contiguous package names - #2566
Merged
Simek merged 1 commit intoJun 24, 2026
Conversation
…package names Co-authored-by: Cursor <cursoragent@cursor.com>
Simek
approved these changes
Jun 24, 2026
Simek
left a comment
Member
There was a problem hiding this comment.
Tested the changes locally and it looks like nice improvement, thanks! 🙏
This approach also makes single word queries more accurate which is a nice side-effect. 🙂
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.
📝 Why & how
Improves search recall for libraries whose names contain all the query words but not as a contiguous substring.
Problem: Searching for
react-native-markdownwould not surface libraries likereact-native-enriched-markdownorreact-native-live-markdownin thecleanedUpNameMatchPoints,npmPkgNameMatchPoints, andrepoNameMatchPointsscoring tiers, because those tiers only checked for contiguous substring matches. The wordenriched/livein the middle broke the match entirely, scoring 0.Solution: After stripping the
react-native/reactprefix from both the query and package name, split into tokens and check if every token appears in the cleaned-up name. This adds a fallback scoring tier to three match checks:npmPkgNameMatchPoints: 125 (contiguous) → 100 (token match) → 0cleanedUpNameMatchPoints: 100 (contiguous) → 75 (token match) → 0repoNameMatchPoints: 50 (contiguous) → 35 (token match) → 0Contiguous substring matches still score higher, so a library like
react-native-markdown-renderercorrectly ranks abovereact-native-enriched-markdownfor the queryreact-native-markdown— but both now appear in results instead of only the former.Nagranie.z.ekranu.2026-06-24.o.13.47.14.mov
✅ Checklist
react-native-libraries.jsonreact-native-libraries.json