code wiki / _hdl_build / nx_onsite_search.nx

nx_onsite_search.nx

buildroot/runtime/_hdl_build/nx_onsite_search.nx

14208 B294 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind tooltopic onsite
docsdependenciesstructsconstsfunctions

about

nx_onsite_search.nx -- REUSABLE per-site onsite search CLIENT (manifest model). ONE BM25 engine pointed at ANY site via a data-driven sites registry (Cardinal 11/17). Each site = its own durable inverted index + MANIFEST + base URL, so a query is SCOPED to exactly that site BY CONSTRUCTION (site A's index file physically cannot return site B's docs). Generalizes nx_search_cli to the wiki/gallery/andelinwest.com and any future site -- "find files and articles" on just that site. REUSE not reinvent: inverted-index shortlist (nx_search_inverted) + the team's Okapi BM25 ranker (bm_*), zero new ranking math. Usage: nx_onsite_search <sites.tsv> <site> <term> [term ...] Registry row (TAB-separated, trailing newline required): site<TAB>idx_path<TAB>manifest_path<TAB>base_url Manifest line (built by nx_onsite_index, docid = line number): url<TAB>title<TAB>text MANIFEST MODEL (vs nx_search_cli's file-per-doc): the searchable text lives INLINE in the manifest, so a 366k-image corpus is ONE file, not 366k tiny files, and BM25 scores in-memory (no per-candidate file reads). Display + scoring are length-based (fields are slices, not NUL-terminated). license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_search_inverted_persist.nx nx_bm25.nx nx_bm25f.nx nx_onsite_search.nx

imports: nx_search_inverted_persist.nxnx_bm25.nxnx_bm25f.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main os_puts sys_read_file sys_openat_rd sys_lseek sys_mmap sys_read sys_close os_lookup_site os_streq nx_inv_load sys_read_file ↻ os_strlen os_fold os_expand nx_inv_query_term nx_inv_hash_bytes_lower nx_inv_lookup_slot nx_inv_slot_at nx_inv_slot_hash nx_inv_slot_postings_count nx_inv_slot_postings_offse nx_inv_slot_write_cursor os_num bm_token_count bmf_score re_count re_strlen bmf_contrib bmf_df re_count ↻ bm_idf_micro bm_ln_micro os_score os_num ↻ os_putb

structs

none

consts

18const OS_MAGIC_1000000: i64 = 1000000
19const OS_MAGIC_10000: i64 = 10000
20const OS_MAGIC_8192: i64 = 8192
22const OS_MAX_TERMS: i64 = 8
23const OS_MAX_X: i64 = 64 // expanded query-term cap (originals + per-site thesaurus concept expansions)
24const OS_ROWID_CAP: i64 = 16384 // matches NX_INV_MAX_POSTINGS_PER (per-term postings cap)
25const OS_TOP_K: i64 = 10

functions

27func os_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main
28func os_putb(p: *u8, n: i64) -> i64 { if n>0 { sys_write(1,p,n) } return 0 }
called by 1: main
29func os_num(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=(48 as u8);k=1}; while m>0{t[k]=((48+(m%10)) as u8);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 }
called by 2: os_scoremain
30func os_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: main
31func os_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]!=(0 as u8){return 0} return 1 }
called by 1: os_lookup_site
32func os_fold(s: *u8, n: i64) -> i64 { var i: i64=0; while i<n { let c: i64=s[i] as i64; if c>=65 { if c<=90 { s[i]=(c+32) as u8 } } i=i+1 } return 0 }
called by 1: main
33func os_score(v: i64) -> i64
called by 1: main calls 1: os_num
43func os_lookup_site(reg: *u8, n: i64, site: *u8, out_idx: *i64, out_mf: *i64, out_base: *i64) -> i64
called by 1: main calls 1: os_streq
80func os_expand(syn: *u8, n: i64, term: *u8, tl: i64, xterms: *i64, xlens: *i64, nx0: i64, scratch: *u8, soff: *i64, scap: i64) -> i64
called by 1: main
127func main(argc: i64, argv: *i64) -> i64