/** * @fileoverview Keyword ranking for Census variables: whole-word matching on label and concept, * an all-terms filter with a most-terms fallback, and one sort-key order with no weights. * @module services/variable-cache/variable-search */ import type { CensusVariable } from './types.js'; /** Result of ranking a variable set against a query. */ export interface VariableSearchResult { /** * Distinct query terms the returned variables contain — every term, unless no variable held * them all and the search fell back to the variables that contain the most. */ matchedTermCount: number; /** Distinct words in the query. Zero when the query holds no letters or digits. */ termCount: number; /** Variables in the returned tier, before any limit. */ totalMatches: number; /** Matching variables in rank order, cut to the limit. */ variables: CensusVariable[]; } /** * Rank `variables` against `query`. * * A term matches a whole word of the label or of the concept. A variable without a concept — a * column shared across tables, whose concept joins every table's — matches on its label alone. A * margin of error matches on its estimate's label: its own opens with `Margin of Error!!`, and * those three words would otherwise rank it alone above its estimate whenever the query holds one * of them ("median value of") that the estimate does not. * A result contains every distinct term; when no variable does, the result is the variables that * contain the most terms, and `matchedTermCount` says how many that was. * * Results sort on four keys in order: where the query phrase appears (see `Placement`), then * fewer `!!` segments in the label, then a shorter concept, then the code. The last key puts an * estimate ahead of its tied margin of error, since `…E` sorts before `…M`. */ export declare function rankVariables(variables: ReadonlyMap, query: string, limit: number): VariableSearchResult; //# sourceMappingURL=variable-search.d.ts.map