Documentation
¶
Overview ¶
Package sqlrank ranks a candidate set of rows in one PostgreSQL statement (#2500): every row whose stored full-text column matches the query, and every row whose blended semantic score reaches opranking.ScoreFloor, scored the way every hybrid ranker on the platform scores and paged with a count of all results.
The candidates are a statement the caller builds, which is how a caller's own filter (an owner, a producer, a person's reach) decides what can be ranked: a row is ranked exactly when that statement would return it. They are materialized and scored by exact distance, because an HNSW scan filters after its nearest-neighbor step and a narrow candidate set would keep few or none of the rows it returned.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRanked ¶
BuildRanked renders a ranked statement over the candidates. Every candidate whose text matches is a result, and so is one whose blended semantic score reaches opranking.ScoreFloor: where the embedding model stops telling related text from unrelated. The candidates are materialized and scored by exact distance, because an HNSW scan filters after its nearest-neighbor step and a narrow reach would keep few or none of the rows it returned. Rows come back as (id, score, total).
Types ¶
type Ranked ¶
Ranked is one ranked page: ids in rank order, each one's score, and how many results there are in all.
type Ranking ¶
type Ranking struct {
// Candidates is a statement selecting id, name, embedding and the stored
// full-text column named FTS, and its arguments ($-numbered).
Candidates string
Args []any
FTS string
QueryText string
Embedding []float32 // nil ranks lexically
Limit int
Offset int
}
Ranking is what a ranked statement scores a candidate set by.