Signature
Description
Performs a comprehensive search across the Quran that combines simple text search with linguistic (lemma/root) analysis and fuzzy fallback. Results are scored, deduplicated, and sorted by relevance. This is your primary API for Quran search results with scoring and pagination.Parameters
string
required
The search query in Arabic text. Non-Arabic characters are automatically stripped during processing.
TVerse[]
required
Array of Quran verses to search. Each verse must satisfy the
VerseInput type with gid, uthmani, and standard fields.Map<number, MorphologyAya>
required
Map of verse morphology data indexed by
gid. Each entry contains lemmas and roots arrays for linguistic matching.WordMap
required
Dictionary mapping normalized query tokens to their canonical lemma and root forms.
AdvancedSearchOptions
default:"{ lemma: true, root: true }"
Search options controlling linguistic matching:
lemma(boolean): Enable lemma-based matchingroot(boolean): Enable root-based matchingfuzzy(boolean, optional): Enable fuzzy fallback matching (default: true)
fuzzy: false to disable fuzzy fallback when no exact/lemma/root matches are found.PaginationOptions
default:"{ page: 1, limit: 20 }"
Pagination controls:
page(number, optional): Page number to retrieve (default: 1)limit(number, optional): Results per page (default: 20)
Returns
object
ScoredVerse[]
Array of matching verses with scoring metadata. Each result includes:
- All original verse fields
matchScore(number): Weighted relevance scorematchType(MatchType): Best match type (‘exact’ | ‘lemma’ | ‘root’ | ‘fuzzy’ | ‘none’)matchedTokens(string[]): Deduplicated matched tokens for highlightingtokenTypes(Record<string, MatchType>): Match type for each token
SearchCounts
Match type breakdown:
simple(number): Verses with exact text matcheslemma(number): Verses with lemma matchesroot(number): Verses with root matchesfuzzy(number): Verses with only fuzzy matchestotal(number): Total matching verses
object
Pagination metadata:
totalResults(number): Total matching verses across all pagestotalPages(number): Total number of pagescurrentPage(number): Current page numberlimit(number): Results per page
Scoring system
Match types are weighted differently:Multi-word queries
The search uses AND logic:- Query is split by whitespace into tokens
- Results must match every token (via exact, lemma/root, or fuzzy fallback)
- Scores accumulate across all matched tokens
Examples
Basic search
With pagination
Disable fuzzy matching
Custom dataset
Notes
- The query is automatically normalized (Arabic normalization, tashkeel removal)
- Non-Arabic characters are stripped from the query
- Empty queries return an empty result set
- Results are sorted by
matchScorein descending order - Use
matchedTokenswithgetHighlightRanges()for UI highlighting