Documentation
¶
Overview ¶
Package search ports the website's client-side fuzzy ranking to Go. Ranking parity with positronick.com is a product guarantee: FuzzyScore, ScoreSoul and ScoreListing are 1:1 ports of fuzzyScore and the relevance() field weights in src/lib/filter.ts and src/lib/listingFilter.ts of the product repo. Change those files first; mirror them here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FuzzyScore ¶
FuzzyScore is the fuzzy match score of needle against haystack: higher is better, 0 means no match. A contiguous substring beats a scattered subsequence; earlier matches beat later ones. Exact port of fuzzyScore in src/lib/filter.ts:
- empty (trimmed) needle: 1 — a universal match
- contiguous substring at index i: 2000 - i
- otherwise subsequence scoring: +5 for a char adjacent to the previous match, +1 for any other matched char; 0 if any char is missing
func RankListings ¶
RankListings filters listings to those scoring > 0 for query and sorts them by score (descending), ties broken by name ascending.
func RankSouls ¶
RankSouls filters souls to those scoring > 0 for query and sorts them by score (descending), like the website's gallery while searching. Ties — and the everything-matches empty query — fall back to name ascending, the site's default sort.
func ScoreListing ¶
ScoreListing is the best fuzzy score of query across a listing's searchable fields, weighted by importance. Exact port of relevance() in src/lib/listingFilter.ts: name x3, tagline x2, profileHandle x2, then profileName, type, description and each tag unweighted; an empty query scores 1.
Types ¶
This section is empty.