rank

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package rank reranks FTS-ranked code-search candidates using dependency-free structural signals (name fuzzy similarity, path proximity), so both the CLI `search` command and the MCP `search` tool share one ranking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchLimit

func FetchLimit(limit int) int

FetchLimit widens the candidate pool pulled from FTS so structural reranking (and any path filtering) has more than the caller's `limit` rows to reorder; the final slice is bounded back to `limit` after reranking. @intent retain enough backend candidates for structural relevance signals to affect the caller's bounded result. @domainRule candidate pools stay between 50 and 500 rows regardless of the requested result limit.

func Rerank

func Rerank(query string, nodes []graph.Node, limit int) []graph.Node

Rerank reorders FTS-ranked search candidates using structural signals fused with the backend rank via Reciprocal Rank Fusion.

@requires nodes is the backend's rank-ordered candidate slice (index == FTS rank). @ensures deterministic output; empty query or empty nodes returns the input bounded by limit, preserving FTS order. @intent combine backend relevance with identifier-name and file-path similarity without losing deterministic FTS tie order.

func RerankGroups added in v0.12.1

func RerankGroups(query string, groups [][]graph.Node, limit int) []graph.Node

RerankGroups fuses several independently ranked candidate lists — one per namespace in federated search — into a single ordering.

Concatenating the lists and calling Rerank would be wrong: Rerank reads a node's array position as its retrieval rank, so the second list's top hit would be charged the first list's length. With a 50-row pool that alone costs it more than the whole structural signal can repay, and every extra namespace makes it worse. Here each node keeps the rank it held inside its own list.

@requires each group is that source's rank-ordered candidate slice. @ensures a node's fused score does not depend on which group it came from or on the order the groups were supplied; empty groups contribute nothing. @intent make federated results comparable across namespaces instead of favouring whichever namespace was queried first.

Types

This section is empty.

Jump to

Keyboard shortcuts

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