Skip to main content

Class: BibleSearchRepository

Defined in: Data/Repositories/BibleSearchRepository.ts:24

Bible Search Repository

Implements search index operations for book-level proximity searching, verse position mapping, saved searches, and search history.

This repository operates on main.db tables:

  • bible_search_index (FTS5 virtual table)
  • bible_search_index_metadata
  • bible_search_verse_positions
  • saved_search
  • search_history

Implements

  • IBibleSearchRepository

Constructors

Constructor

new BibleSearchRepository(sql): BibleSearchRepository

Defined in: Data/Repositories/BibleSearchRepository.ts:25

Parameters

sql

ISql

Returns

BibleSearchRepository

Methods

addSearchHistory()

addSearchHistory(query, searchType, resultCount): void

Defined in: Data/Repositories/BibleSearchRepository.ts:402

Add a search to history

Parameters

query

string

searchType

string

resultCount

number

Returns

void

Implementation of

IBibleSearchRepository.addSearchHistory


batchInsertVersePositions()

batchInsertVersePositions(positions): void

Defined in: Data/Repositories/BibleSearchRepository.ts:290

Batch insert verse positions (for indexing)

Parameters

positions

BibleSearchVersePosition[]

Returns

void

Implementation of

IBibleSearchRepository.batchInsertVersePositions


buildBookIndex()

buildBookIndex(document, division, bookText, versePositions): void

Defined in: Data/Repositories/BibleSearchRepository.ts:49

Build book-level search index

Parameters

document

string

Module abbreviation (e.g., "kjv")

division

string

Book number as string (e.g., "1" for Genesis)

bookText

string

Complete book text for indexing

versePositions

BibleSearchVersePosition[]

Verse position mappings

Returns

void

Implementation of

IBibleSearchRepository.buildBookIndex


clearBookIndex()

clearBookIndex(document, division): void

Defined in: Data/Repositories/BibleSearchRepository.ts:87

Clear book index (marks for re-indexing)

Parameters

document

string

division

string

Returns

void

Implementation of

IBibleSearchRepository.clearBookIndex


clearSearchHistory()

clearSearchHistory(): void

Defined in: Data/Repositories/BibleSearchRepository.ts:435

Clear search history

Returns

void

Implementation of

IBibleSearchRepository.clearSearchHistory


deleteBookIndex()

deleteBookIndex(document, division): void

Defined in: Data/Repositories/BibleSearchRepository.ts:96

Delete book index completely

Parameters

document

string

division

string

Returns

void

Implementation of

IBibleSearchRepository.deleteBookIndex


deleteOldHistory()

deleteOldHistory(daysToKeep): number

Defined in: Data/Repositories/BibleSearchRepository.ts:439

Delete old search history entries (older than N days)

Parameters

daysToKeep

number

Returns

number

Implementation of

IBibleSearchRepository.deleteOldHistory


deleteSavedSearch()

deleteSavedSearch(searchId): boolean

Defined in: Data/Repositories/BibleSearchRepository.ts:369

Delete a saved search

Parameters

searchId

number

Returns

boolean

Implementation of

IBibleSearchRepository.deleteSavedSearch


getIndexedBooks()

getIndexedBooks(document): BibleSearchIndex[]

Defined in: Data/Repositories/BibleSearchRepository.ts:131

Get all indexed books for a document

Parameters

document

string

Returns

BibleSearchIndex[]

Implementation of

IBibleSearchRepository.getIndexedBooks


getIndexMetadata()

getIndexMetadata(document, division): BibleSearchIndex | undefined

Defined in: Data/Repositories/BibleSearchRepository.ts:40

Get index metadata for a book

Parameters

document

string

division

string

Returns

BibleSearchIndex | undefined

Implementation of

IBibleSearchRepository.getIndexMetadata


getPopularSavedSearches()

getPopularSavedSearches(limit?): SavedSearch[]

Defined in: Data/Repositories/BibleSearchRepository.ts:388

Get most frequently used saved searches

Parameters

limit?

number = 10

Returns

SavedSearch[]

Implementation of

IBibleSearchRepository.getPopularSavedSearches


getRecentSavedSearches()

getRecentSavedSearches(limit?): SavedSearch[]

Defined in: Data/Repositories/BibleSearchRepository.ts:377

Get recently used saved searches

Parameters

limit?

number = 10

Returns

SavedSearch[]

Implementation of

IBibleSearchRepository.getRecentSavedSearches


getSavedSearch()

getSavedSearch(searchId): SavedSearch | undefined

Defined in: Data/Repositories/BibleSearchRepository.ts:340

Get a saved search by ID

Parameters

searchId

number

Returns

SavedSearch | undefined

Implementation of

IBibleSearchRepository.getSavedSearch


getSavedSearches()

getSavedSearches(): SavedSearch[]

Defined in: Data/Repositories/BibleSearchRepository.ts:333

Get all saved searches

Returns

SavedSearch[]

Implementation of

IBibleSearchRepository.getSavedSearches


getSearchHistory()

getSearchHistory(limit?): object[]

Defined in: Data/Repositories/BibleSearchRepository.ts:411

Get recent search history

Parameters

limit?

number = 20

Returns

object[]

Implementation of

IBibleSearchRepository.getSearchHistory


getUnindexedBooks()

getUnindexedBooks(document): BibleSearchIndex[]

Defined in: Data/Repositories/BibleSearchRepository.ts:121

Get all unindexed books for a document

Parameters

document

string

Returns

BibleSearchIndex[]

Implementation of

IBibleSearchRepository.getUnindexedBooks


getVerseIdAtPosition()

getVerseIdAtPosition(document, division, position): number | undefined

Defined in: Data/Repositories/BibleSearchRepository.ts:246

Get the verse ID at a specific character position in the book text

Parameters

document

string

division

string

position

number

Returns

number | undefined

Implementation of

IBibleSearchRepository.getVerseIdAtPosition


getVersePosition()

getVersePosition(document, division, verseId): BibleSearchVersePosition | undefined

Defined in: Data/Repositories/BibleSearchRepository.ts:261

Get verse position information

Parameters

document

string

division

string

verseId

number

Returns

BibleSearchVersePosition | undefined

Implementation of

IBibleSearchRepository.getVersePosition


getVersesInRange()

getVersesInRange(document, division, startPos, endPos): BibleSearchVersePosition[]

Defined in: Data/Repositories/BibleSearchRepository.ts:274

Get all verses that overlap a character position range

Parameters

document

string

division

string

startPos

number

endPos

number

Returns

BibleSearchVersePosition[]

Implementation of

IBibleSearchRepository.getVersesInRange


isBookIndexed()

isBookIndexed(document, division): boolean

Defined in: Data/Repositories/BibleSearchRepository.ts:31

Check if a book is indexed for proximity search

Parameters

document

string

division

string

Returns

boolean

Implementation of

IBibleSearchRepository.isBookIndexed


saveSearch()

saveSearch(search): SavedSearch

Defined in: Data/Repositories/BibleSearchRepository.ts:307

Save a search query

Parameters

SavedSearch

Returns

SavedSearch

Implementation of

IBibleSearchRepository.saveSearch


searchFTS5()

searchFTS5(document, fts5Query, division?): FTS5Match[]

Defined in: Data/Repositories/BibleSearchRepository.ts:162

Raw FTS5 query (for advanced boolean searches)

Parameters

document

string

fts5Query

string

division?

string

Returns

FTS5Match[]

Implementation of

IBibleSearchRepository.searchFTS5


searchPhrase()

searchPhrase(document, phrase, division?): FTS5Match[]

Defined in: Data/Repositories/BibleSearchRepository.ts:156

Search for exact phrase in book-level index

Parameters

document

string

phrase

string

division?

string

Returns

FTS5Match[]

Implementation of

IBibleSearchRepository.searchPhrase


searchProximity()

searchProximity(document, terms, maxDistance, division?): FTS5Match[]

Defined in: Data/Repositories/BibleSearchRepository.ts:145

Search for terms within a specific proximity using FTS5 NEAR

Parameters

document

string

Module abbreviation

terms

string[]

Array of search terms

maxDistance

number

Maximum word distance between terms

division?

string

Optional book number to limit search to specific book

Returns

FTS5Match[]

Array of FTS5 matches with positions

Implementation of

IBibleSearchRepository.searchProximity


updateSavedSearch()

updateSavedSearch(search): SavedSearch

Defined in: Data/Repositories/BibleSearchRepository.ts:348

Update a saved search

Parameters

search

SavedSearch

Returns

SavedSearch

Implementation of

IBibleSearchRepository.updateSavedSearch