UNPKG

@athenox/talos

Version:

Talos: a backend you describe instead of write. Declare a schema, write the rules in plain language, map URLs to sentences; a small built-in model turns them into query plans.

29 lines (28 loc) • 1.21 kB
/** * Full-text search over the rows a route's plan chose, without an index to * keep in step with every write. * * Per query word, each row's fields are scored BM25-style with their weights * (`{ title: 3, excerpt: 2, content: 1 }`). A word matches a row word that is * equal, that it starts (typing "schno" finds "schnockele"), or — for words of * five letters or more — one edit away (a typo). The embedder then adds the * meaning of the whole query against the row's text (30 %), so "match de foot" * also finds "la finale de football". Rows with no word matched and little * meaning in common are left out. * * Token lists are cached by text, so repeated searches over the same rows cost * the scoring only. */ export type FindOptions = { q: string; /** physical text columns and their weights */ fields: Record<string, number>; /** strip HTML tags from the fields first (an article body) */ html?: boolean; limit?: number; /** autocompletion: the rows whose `suggest` field has a word starting with the query's last word */ suggest?: string; }; type Row = Record<string, any>; export declare function find(rows: Row[], o: FindOptions): Row[]; export {};