search

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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

func FuzzyScore(needle, haystack string) int

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

func RankListings(query string, listings []api.Listing) []api.Listing

RankListings filters listings to those scoring > 0 for query and sorts them by score (descending), ties broken by name ascending.

func RankSouls

func RankSouls(query string, souls []api.SoulCard) []api.SoulCard

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

func ScoreListing(query string, l api.Listing) int

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.

func ScoreSoul

func ScoreSoul(query string, s api.SoulCard) int

ScoreSoul is the best fuzzy score of query across a soul's searchable fields, weighted by importance. Exact port of relevance() in src/lib/filter.ts: name x3, tagline x2, authorHandle x1, each tag and framework unweighted; an empty query scores 1 (matches everything).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL