Skip to content

VaultMD / SearchHit

Type Alias: SearchHit

SearchHit = object

Defined in: src/query/models/search-hit.ts:6

A note plus the text around what matched — returned by QueryApi.searchText, QueryApi.unlinkedMentions and QueryApi.outboundMentions.

Properties

path

path: string

Defined in: src/query/models/search-hit.ts:8

Vault-relative path of the matching note.


score?

optional score?: number

Defined in: src/query/models/search-hit.ts:38

Relevance of this hit, higher is better. It is SQLite fts5's BM25 rank negated: fts5 itself scores with negative numbers where more negative is the better match (which is why its rank order is ascending), and handing that sign to callers makes every threshold read backwards.

Unbounded above, and comparable only within one query's results. BM25 weighs a term by how rare it is across the vault and how short the matching note is, so the same number means different things for different query strings, and drifts as the vault grows — a read-scoped instance is even ranked against the whole index, not the subset it can read. Compare hits against each other, or against the top hit, never against a constant.

Present on every QueryApi.searchText hit, and only there. QueryApi.unlinkedMentions and QueryApi.outboundMentions return hits without it: they match a note's names in prose rather than running one ranked query, so any number attached to them would be per-name, unordered, and missing for a name fts5 cannot tokenize — none of the properties documented above.


snippet?

optional snippet?: string

Defined in: src/query/models/search-hit.ts:17

Excerpt showing where the match sits, with the matched text wrapped in <b> and where the excerpt is cut. searchText builds it with fts5's snippet(); the mention methods build the equivalent around the name they matched. Absent when the caller asked for no snippet.


title

title: string

Defined in: src/query/models/search-hit.ts:10

Derived title of the matching note.