/** * @fileoverview The Local REST API's `POST /search/simple/` run in-server, for * text searches under a read scope: plugin 5.2.0's `simpleSearch` over * Obsidian 1.14.5's `prepareSimpleSearch`. The query is lower-cased and split * on single spaces; a note matches when every token occurs in its lower-cased * `basename + "\n\n" + body`. Each token's occurrences are found by `indexOf`, * resuming one character past the end of the last, so an occurrence that * touches or overlaps the previous one is skipped; the occurrences of every * token are sorted and merged where they overlap or touch. A merged range * inside the basename is a `filename` span whose context is the basename, one * inside the body a `content` span with a `contextLength` window either side, * widened one code unit rather than split a surrogate pair, and one across the * two is dropped. Offsets index the lower-cased text, and windows are cut from * the original, as the plugin cuts them. Hits are ordered by Obsidian's score, * highest first, ties in the order notes were added (the plugin's vault order). * @module services/obsidian/simple-search */ /** A span as `/search/simple/` reports it, plus where `match.start` sits in `context`. */ export interface SimpleSearchSpan { context: string; contextStart: number; match: { end: number; source: 'content' | 'filename'; start: number; }; } /** A note's `/search/simple/` hit. */ export interface SimpleSearchHit { filename: string; matches: SimpleSearchSpan[]; score: number; } /** * The query's tokens as `prepareSimpleSearch` reads them: lower-cased, split * on single spaces (a tab or newline stays inside its token), empty pieces * dropped. Repeats are dropped too: Obsidian scans a repeated token again, but * its ranges coincide with the first scan's and merge away. */ export declare function simpleSearchTokens(query: string): string[]; export declare const isHighSurrogate: (cu: number) => boolean; export declare const isLowSurrogate: (cu: number) => boolean; /** * One text search over notes added in vault order, holding each hit's context * windows. `maxResponseChars` bounds the plugin's response for those hits, its * length as `JSON.stringify(hits, null, 2)` (see `HIT_FRAME`): every hit's * filename and score, every span's offsets and escaped window, and the framing * around each. The count grows span by span as each note is added, so the * span that passes the bound fails the search with `context_length_too_large` * at once, and no more spans are held than a response the plugin could send. */ export declare class SimpleSearch { #private; /** The distinct non-empty tokens; a note matches only when it holds every one. */ readonly tokens: readonly string[]; constructor(query: string, contextLength: number, maxResponseChars?: number); /** Match one note, `body` as Obsidian's `cachedRead` gives it. */ add(path: string, body: string): void; /** The hits, highest score first; equal scores keep the order their notes were added. */ hits(): SimpleSearchHit[]; } //# sourceMappingURL=simple-search.d.ts.map