Documentation
¶
Overview ¶
Package passages splits extracted Markdown into heading-aware chunks and ranks them against a query with BM25. It backs `POST /v1/extract` ("BM25-ranked passages across 1..20 URLs").
This is the Go home of the Cloudflare hub's chunker and ranker (chunkMarkdownForSearch and rankChunksInMemory in hub/src/search-index.ts). The hub parity test (cmd/edgefetch/hub_parity_test.go) holds the two to the same answers until the hub stops processing pages (docs/HUB-NODE-PROCESSING-PLAN.md). Lengths count runes, which matches the hub's UTF-16 lengths for all text outside the astral planes.
Index ¶
Constants ¶
const ( // DefaultChunkChars is the target chunk size, in characters. DefaultChunkChars = 1500 // DefaultChunkOverlap is how much trailing prose a chunk repeats from the one before it. DefaultChunkOverlap = 150 )
Variables ¶
This section is empty.
Functions ¶
func QueryTerms ¶
QueryTerms are the distinct lowercase terms of at least two characters in a query, at most twelve.
Types ¶
type Chunk ¶
type Chunk struct {
Ordinal int `json:"ordinal"`
Heading string `json:"heading"`
Text string `json:"text"`
Score float64 `json:"score,omitempty"`
}
Chunk is one passage of a document.