The main search function accepts two optional configuration layers allowing fine-tuned control over behavior and pagination limits.
SearchOptionsToggles linguistic matching logic. Enabling Lemma & Root requires you to pass valid morphologyMap and wordMap payloads.
export type AdvancedSearchOptions = {
// Required mapping variables
lemma: boolean;
root: boolean;
// Optional matching variables
fuzzy?: boolean; // Default: true
isRegex?: boolean;
semantic?: boolean;
// Optional geographic filtering parameters
suraId?: number;
juzId?: number;
suraName?: string;
sura_name_en?: string;
sura_name_romanization?: string;
};
export type SearchOptions = AdvancedSearchOptions;
fuzzy is allowed to fallback if exact/lemma/root checks fail. Pass { fuzzy: false } to strictly enforce absolute dict matches.{ isRegex: true } processes the query as a regular expression instead of standard token matching. The pattern is validated for syntactic correctness and checked against known ReDoS-prone patterns (nested quantifiers, overlapping alternation) before execution. Throws InvalidRegexError for invalid or unsafe patterns. Regex search bypasses all linguistic pipelines (lemma, root, fuzzy) and matches directly against the normalized standard text field. Can be combined with suraId, juzId, or suraName to narrow the search scope.{ semantic: true } to integrate with AI embeddings conditionally if valid data map shapes are configured.{ suraId: 2, juzId: 3 } etc.PaginationOptionsControl bounds limit constraints natively. Omitting these defaults to logical page limits (typically page 1, limit 50).
export type PaginationOptions = {
page?: number; // Starting return page.
limit?: number; // Count return offset per page limit.
};