code wiki / _hdl_build / nx_onsite_search.nx
nx_onsite_search.nx
buildroot/runtime/_hdl_build/nx_onsite_search.nx
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
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
structs
| none |
consts
| 18 | const OS_MAGIC_1000000: i64 = 1000000 |
| 19 | const OS_MAGIC_10000: i64 = 10000 |
| 20 | const OS_MAGIC_8192: i64 = 8192 |
| 22 | const OS_MAX_TERMS: i64 = 8 |
| 23 | const OS_MAX_X: i64 = 64 // expanded query-term cap (originals + per-site thesaurus concept expansions) |
| 24 | const OS_ROWID_CAP: i64 = 16384 // matches NX_INV_MAX_POSTINGS_PER (per-term postings cap) |
| 25 | const OS_TOP_K: i64 = 10 |
functions
| 27 | func 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 |
| 28 | func os_putb(p: *u8, n: i64) -> i64 { if n>0 { sys_write(1,p,n) } return 0 } called by 1: main |
| 29 | func 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 } |
| 30 | func os_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } called by 1: main |
| 31 | func 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 |
| 32 | func 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 |
| 33 | func os_score(v: i64) -> i64 |
| 43 | func os_lookup_site(reg: *u8, n: i64, site: *u8, out_idx: *i64, out_mf: *i64, out_base: *i64) -> i64 |
| 80 | func 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 |
| 127 | func main(argc: i64, argv: *i64) -> i64 |