Motivation
With separatesources enabled (the default), a package with the exact
searched name that exists in several sync repos can be listed in the
wrong order. For example, if [cachyos-extra-v3] comes before [extra] in
pacman.conf, extra/chromium can still show up as the top pick instead of
cachyos-extra-v3/chromium. pacman prefers the repo listed first.
separateSourceScore returned a flat 50 for every exact match, whatever
its source. As a result, all exact matches got the same metric
(50 + 1.0). The unstable slices.SortFunc then left their relative order
unspecified, so the ordering added for non-exact results did not apply
to exact ones.
Approach
Move the repo-order scoring into a repoOrderScore helper (same logic and
cache as before). For exact matches, add repoOrderScore/separateSourceMax
to the 50: a bonus between 0 and 1. Exact matches still outrank every
non-exact result (which scores at most 45 + a metric below 1). Among
exact matches, repos earlier in pacman.conf now come first. Exact AUR
matches keep 50, so an exact sync-repo match now ranks strictly above an
exact AUR match instead of tying with it. Scoring for non-exact results
is unchanged, and nothing changes when separatesources is disabled.
Validation
- go test -race ./pkg/query/... -count=1: passes.
- New tests TestSourceQueryBuilderExactMatchSortsByRepoOrder (top-down
and bottom-up) and TestSeparateSourceScore_ExactMatchKeepsRepoOrder
fail with the previous metric.go and pass with this change.
- golangci-lint run ./pkg/query/...: 0 issues; gofmt clean.
- go test ./... on macOS has failures that also occur on the unchanged
base: Linux-only syscall fields in pkg/settings/exe, and a
timezone-dependent test in pkg/text. Not tested against a real
pacman setup with custom repos.
Report: https://github.com/Jguer/yay/issues/2986
Assisted-by: claude-opus-5-5 (via Claude Code)
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Co-authored-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
- Join search terms with space instead of empty separator so Jaro-Winkler
similarity compares against realistic strings (e.g. 'linux ck' vs 'linuxck')
- Change matchesSearch symbol check from early return to continue so non-symbol
terms in multi-term queries are still filtered instead of being bypassed
* query: precompute metricScore once per result
Normalize the search term and name/provider/desc at the metric boundary, drop the per-comparison distance cache, and score each result via prepareMetrics before sorting. Adds a search-flow benchmark to track regressions.
* update deps
fix(query): use JaroWinkler distance and reweight metric components
Switch from Hamming to JaroWinkler distance for package name matching,
as JaroWinkler handles variable-length strings and gives a prefix-match
bonus better suited to package search.
Reweight the score components from sim*0.50 + simDesc*0.20 + popularity*0.30
to sim*0.35 + simDesc*0.15 + popularity*0.50 to better surface popular
packages when name similarity is moderate.
Roll back the unreleased version target from 13.0.0 to 12.6.0 to align
with the next minor release after v12.5.7.
Fix scanner.Err() check in parseStdin to surface I/O errors that were
previously silently dropped.
Replace vote-only sigmoid with a blended votes+popularity score in
aurSortByMetric. AUR's Popularity field (already stored and populated
from the API) is a time-decayed vote score that better reflects current
relevance than raw NumVotes alone.
Falls back to votes-only when popularity <= 0 (brand-new packages).
Uses the same sigmoid normalization pattern as the existing minVotes
constant (minPopularity = 0.5).
Side effect: AUR packages no longer artificially outscore repo packages
via historical vote counts when separateSources is disabled. Updated
two noseparatesources test expectations accordingly.
* Add all sortyby options
Previously, only 'name' was a supported sortby option. Now, all sortby
options are supported.
Whenever there is a tie, the metric is used as a tiebreaker (it is also
the default when sortby is not specified). The only behavior that
changed is that packages with the same metric are sorted oppositely when
sorting bottomUp. This was actually a bug in the previous implementation
which inverts the `cmpResult` for bottomUp which returns true if the
metrics are the same. According to the docs for Less
(https://pkg.go.dev/sort#Interface), Less(i, i) should be false (the
same element cannot sort before itself).
I mainly structured the code for efficiency by creating the sortby
function once rather than checking `separateSources` and `bottomUp`
every comparison, but I also think this improves readability compared to
having a switch-case in the comparison function.
* Fix separating sources on ties and improve test coverage
* Remove 'id' and 'baseid' in sortby options
* ci(yay): update packages on builder before building release
* respect other repos in order
* ensure repo ends on top in case of tie
* revert dockerfile change
* Make package names clickable links to their repo pages using OSC 8 sequences (official arch repos and AUR only)
* fmt
* Map "devel" repo to AUR when creating package links
* Revert pkg/upgrade/upgrade.go This wasn't supposed to be here yet.
* rework relationship between runtime and cfg
* separate runtime from cfg
* simplify instantiation logic
* move installer to appropriate package
* move operator to sync package
* add tests for srcinfo service
* consolidate srcinfo service in sync
* add logger to srcinfo
* add logger to preparer
* remove unused text functions
* remove remaining text.* from srcinfo
* remove global logger parts
* remove global org method exports
* remove global logger
* move text->input
* add rule to prevent fmt.Print
* update golangci go version
* remove outdated FAQs
* remove outdated FAQs
* use logger in dep graph
* use logger in dep graph
* use logger in dep graph
* only query for AUR packages once per tier. useful for rpc
* fix performance regression for ros-melodic
* prefer name search first
* implement needed at target gathering
* set default config
* fixup tests for needed
* show new packages in upgrade form if they exist
* refactor up select
* remove unused graph parts
* readd len
* Complete upgrade graphing
* Extract to upgrade pkg
* remove unused dep method
* remove uneeded dep
* cleanup method
* specify io Reader for testing
* use specified input vector
* fix non-active devel
* test base cases
* add devel test cases
* add range tests
* add logger struct
* use logger struct in upgrade
* follow golangci recommendations
* update deps
* update golangci