search

package
v0.229.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Browse artifacts for the client-side reader. Alongside the per-language search indexes (search.go), the build emits a single global doc-id space (one entry per Work, in catalog order) as two RoaringRange sidecars the Hugo WASM reader opens directly:

  • browse-facets.rrsf -- an RRSF facet sidecar (language/format/subject/ tag/classification/contributor -> doc-id postings), for client-side facet counts and filtering without pre-rendered facet pages.
  • browse-records.bin/.idx -- an RRSR record store mapping a doc id to its compact result-card JSON, for rendering result rows without a page load.

browse-docs.json maps each doc id to its Work id, so the per-language search hits (which carry Work ids via their own docs maps) bridge into this global space, and a card links to the static /works/<id> detail page. browse-subjects.json maps each subject id to its labels + vocabulary scheme, so the fallback facet panel renders localized, scheme-grouped subjects .

Package search builds the catalog's lexical search index from the projected catalog (ARCHITECTURE §8). Per corpus language it emits, by script: a roaringrange term index (.rrt, boolean whole-word presence) paired with a BM25 impact sidecar (.rrb) for segmented scripts, or a trigram index (.rrs, RRSI) for unsegmented scripts (CJK/Thai/...) where word-level tokenization fails. A manifest routes each language to its index and kind -- the data the browser's reader queries. Building is done in Go; term-index queries run in the Rust/WASM reader the Hugo module ships, while the trigram (RRSI) index has a Go reader too.

Index

Constants

View Source
const (
	BrowseIndexName    = "browse-index.rrs"
	BrowseRecordsBin   = "browse-records.bin"
	BrowseRecordsIdx   = "browse-records.idx"
	BrowseFacetsName   = "browse-facets.rrsf"
	BrowseDocsName     = "browse-docs.json"
	BrowseSubjectsName = "browse-subjects.json"
)

Browse artifact filenames.

View Source
const (
	FacetLanguage       = "language"
	FacetFormat         = "format"
	FacetSubject        = "subject"
	FacetTag            = "tag"
	FacetClassification = "classification"
	FacetContributor    = "contributor"
)

Facet field names in the RRSF sidecar; the reader's filter pairs ([field, category]) and the Hugo facet UI key on these.

View Source
const SchemaVersion = 3

SchemaVersion is the search-manifest schema version, checked by the reader. v2 adds the per-language BM25 impact sidecar (IndexInfo.Impacts); v3 adds the trigram (RRSI) index kind for unsegmented scripts (IndexInfo.Kind/GramSize).

Variables

This section is empty.

Functions

func BuildBrowse

func BuildBrowse(cat *project.Catalog, sink storage.Sink) error

BuildBrowse emits the facet sidecar, record store, and doc-id->Work-id map over a global doc-id space dense from 0 in catalog order.

Types

type IndexInfo

type IndexInfo struct {
	Language     string `json:"language"`           // ISO 639-2 code, or "und" when undeclared
	Kind         string `json:"kind"`               // "terms" (RRTI) or "trigram" (RRSI)
	TermLanguage uint8  `json:"termLanguage"`       // terms: roaringrange stemmer-language byte
	Stemmed      bool   `json:"stemmed"`            // terms only
	Stopwords    bool   `json:"stopwords"`          // terms only
	GramSize     int    `json:"gramSize,omitempty"` // trigram: n-gram size
	Index        string `json:"index"`              // .rrt or .rrs filename
	Impacts      string `json:"impacts,omitempty"`  // terms: .rrb BM25 impact sidecar
	Docs         string `json:"docs"`               // JSON array: doc id (index) -> Work id
	DocCount     int    `json:"docCount"`
}

IndexInfo describes one per-language index and how it was tokenized, so the reader tokenizes queries identically. Kind selects the query path: "terms" is a word-level RRTI index (.rrt) with optional stemming + BM25 sidecar; "trigram" is an RRSI n-gram index (.rrs) for unsegmented scripts, queried by NgramKeys.

type Manifest

type Manifest struct {
	Version int         `json:"version"`
	Indexes []IndexInfo `json:"indexes"`
}

Manifest is the language->index routing map the browser reader loads: one entry per language present in the corpus (§8).

func BuildIndexes

func BuildIndexes(cat *project.Catalog, sink storage.Sink) (Manifest, error)

BuildIndexes writes one index per corpus language into sink -- a word-level term index (+ BM25 sidecar) for segmented scripts, or a trigram (RRSI) index for unsegmented ones -- plus a doc-id->Work-id list per index and a search-manifest.json routing map. A Work is indexed once per language it declares; a Work with none goes to the undetermined index. Doc ids are dense from 0 in the projected (sorted) order.

Jump to

Keyboard shortcuts

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