Skip to main content
The search() function accepts any dataset shape as long as each record satisfies the VerseInput type. This allows you to use custom Quran datasets with additional fields like translations, tafsir, or metadata.

VerseInput requirements

From src/types/index.ts:16-20:

Minimum requirements

  • gid: number - Unique verse ID (used to join with morphologyMap)
  • standard: string - Used for exact text matching
  • uthmani: string - Used for fuzzy fallback and commonly used for highlighting in UI
If you don’t have separate Uthmani text, set uthmani to the same value as standard.

Basic custom dataset

Here’s a minimal example with custom fields:
When using custom datasets without morphology data, set lemma: false and root: false in search options. The search will use exact text matching only.

Full example from README

From the README (lines 302-332):

With morphology data

For lemma/root matching, provide both morphology map and word map:

MorphologyAya structure

From src/types/index.ts:22-26:

WordMap structure

From src/types/index.ts:28-33:

Complete example

TypeScript support

The search() function is generic and preserves your custom type:
From src/core/search.ts:303-310:

Multiple translations

You can include multiple translations in your custom dataset:

GID mapping

Ensure that your gid values match the gid keys in your morphologyMap. The search engine uses gid to join verse data with morphology data.
The gid (global ID) must be:
  • Unique for each verse
  • Consistent between your verse data and morphology data
  • A positive integer

Empty morphology

If you don’t have morphology data, you can use empty collections:
Without morphology data, the search will only perform exact text matching and fuzzy fallback (if enabled).

Additional metadata

You can include any additional metadata in your custom type:
All fields are preserved in search results and fully typed when using TypeScript.