fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

shards: use repo priority in match scores (#458)

In the original zoekt code base each repository has a uint16 called Rank
which is computed from repository signals like star count.
zoekt-sourcegraph-indexserver did not set those signals, instead we
created our own field which is a float64 called priority. In practice
this value is just the star count.

This commit detects empty rank fields and sets them using the same
calculation based on priority. This will make Zoekt's ranking now use
star count as a signal.

Note: when we are ready, we can use more advanced signals as the
input (and code-intel is working on that).

Note: this won't affect current ranking on Sourcegraph since we bucketed
by star count => repos in the same bucket will have the same rank.

Test Plan: Ran zoekt-webserver with an extra log line and observed it
logging Rank values. Additionally rank some searches with "debug=1" set
in the URL params and observed influences on the computed scores.

log.Println("RANK", repo.Name, repo.Rank)

go run ./cmd/zoekt-webserver -listen 127.0.0.1:6070

+8
+8
shards/shards.go
··· 971 971 if priority > maxPriority { 972 972 maxPriority = priority 973 973 } 974 + 975 + // No one is reading s yet, so we can mutate it. 976 + // zoekt-sourcegraph-indexserver does not set Rank so at this point we 977 + // treat Priority like star count and set it. 978 + if repo.Rank == 0 && priority > 0 { 979 + l := math.Log(float64(priority)) 980 + repo.Rank = uint16((1.0 - 1.0/math.Pow(1+l, 0.6)) * 10000) 981 + } 974 982 } 975 983 } 976 984