code wiki / _hdl_build / nx_estate_search_lib.nx
nx_estate_search_lib.nx
buildroot/runtime/_hdl_build/nx_estate_search_lib.nx
about
nx_estate_search_lib.nx -- THE ESTATE QUERY, as a library so a gate drives it in-process on a fixture shard
(search rungs E1/E1b/E4, 2026-09-14). es_query ranks with dss_search (the SAME scorer the public search runs: one
ruler, two corpora) and renders one line per hit into a caller buffer: rank TAB score TAB url (the url row,
else doc:<cid>) TAB snippet (the first ES_SNIPPET bytes of the document with control bytes folded to spaces).
It returns the hit count, or ES_UNREADABLE when the shard cannot be opened -- an absent shard and an empty one
are different facts and only one of them is a defect.
E1b DEFINITION PRECEDENCE: an underscored term is also asked as its definition token (ss_def_token, the token
the tree ingest writes once per function head), and the hits are re-ordered by a TIER before the score -- a
document carrying a typed term's definition token ranks above one that only mentions the term, whatever the
BM25 magnitude (es_def_precedence, the shape of dss_exact_precedence: a lexicographic key needs no coefficient,
and a discount constant here would be a magic number nobody could justify). A one-word function name has no
definition tier -- a NAMED residual, the same condition ss_ident_collapse already draws. license_tier: ORIGINAL
dependencies 2 imports · 2 importers
imports: nx_docportal_search_serve.nxnx_uxf_cid.nx
imported by: nx_estate_search.nxnx_estate_search_gate.nx
structs
| none |
consts
| 16 | const ES_DOMAIN: *u8 = "estate" |
| 17 | const ES_TOP_DEFAULT: i64 = 10 |
| 18 | const ES_TOP_MAX: i64 = 50 |
| 19 | const ES_QBUF: i64 = 1024 |
| 20 | const ES_SNIPPET: i64 = 160 |
| 21 | const ES_PREFIXBUF: i64 = 512 |
| 22 | const ES_KEYBUF: i64 = 64 |
| 23 | const ES_BOX: i64 = 16 |
| 24 | const ES_WORD: i64 = 8 |
| 25 | const ES_NUMBUF: i64 = 28 |
| 26 | const ES_TAB: i64 = 9 |
| 27 | const ES_LF: i64 = 10 |
| 28 | const ES_SPACE: i64 = 32 |
| 29 | const ES_DIGIT0: i64 = 48 |
| 30 | const ES_DIGIT9: i64 = 57 |
| 31 | const ES_MMAP_OPEN: i64 = 1 // ss_open2 mode: mmap the segments, never read a multi-GB shard into anon RAM |
| 32 | const ES_UNREADABLE: i64 = 0 - 3 // es_query: the shard could not be opened (the program exits 3 on it) |
| 33 | const ES_LINE_RESERVE: i64 = 256 // per hit: rank, score, tabs, doc:<cid> and the newline beside the url and snippet |
| 34 | const ES_DEFOFF: i64 = DSS_MAXTERMS // at most one definition token per query term the scorer will read |
| 35 | const ES_LOOKUP_TERMS: i64 = 1 // a one-term query is a LOOKUP: it also asks for that term's definition token (a rung id, a bare name); prose has more |
| 282 | const ES_UXF_HEAD_FIELDS: i64 = 5 // q hits top shard segments |
| 283 | const ES_UXF_HIT_FIELDS: i64 = 4 // rank score url snippet |
| 284 | const ES_UXF_HIT_COLS: i64 = ES_UXF_HIT_FIELDS - 1 // TAB separators per rendered hit line |
| 285 | const ES_UXF_KEYLEN: i64 = 24 // "hit." + up to two digits of ES_TOP_MAX + ".snippet" + NUL, the longest key |
functions
| 37 | func es_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 38 | func es_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { d[o + i] = s[i]; i = i + 1 } return o + i } |
| 39 | func es_catn(d: *u8, o: i64, v: i64) -> i64 |
| 49 | func es_starts(a: *u8, p: *u8) -> i64 { var i: i64 = 0; while p[i] != (0 as u8) { if a[i] != p[i] { return 0 } i = i + 1 } return 1 } called by 1: main |
| 50 | func es_atoi(s: *u8) -> i64 called by 1: main |
| 57 | func es_find(hay: *u8, n: i64, needle: *u8) -> i64 |
| 73 | func es_has_word(doc: *u8, dn: i64, tok: *u8) -> i64 |
| 94 | func es_def_precedence(defa: i64, sca: i64, defb: i64, scb: i64) -> i64 called by 1: es_query |
| 103 | func es_query(domain: *u8, q: *u8, qn: i64, top: i64, out: *u8, cap: i64, olen: *i64, segs_out: *i64) -> i64 |
| 265 | func es_summary(out: *u8, o0: i64, q: *u8, hits: i64, top: i64, prefix: *u8, segs: i64) -> i64 |
| 288 | func es_uxf_dup(src: *u8, n: i64) -> *u8 called by 1: es_uxf_envelope |
| 297 | func es_uxf_hitkey(i: i64, col: *u8) -> *u8 |
| 312 | func es_uxf_envelope(rendered: *u8, rn: i64, q: *u8, hits: i64, top: i64, prefix: *u8, segs: i64, canon_out: *u8, cid: *u8, fields_out: *i64) -> i64 |
| 360 | func es_uxf_envelope_size(rendered: *u8, rn: i64, q: *u8, hits: i64, top: i64, prefix: *u8, segs: i64) -> i64 calls 1: es_uxf_envelope |