Skip to main content

Class: SearchQueryParser

Defined in: Services/SearchQueryParser.ts:23

Search Query Parser

Parses search queries with complex syntax including:

  • Phrase search: "exact phrase"
  • Word proximity search: word1 word2 ~50w or word1 word2 ~50
  • Verse proximity search: word1 word2 ~5v
  • Boolean operators: AND, OR, NOT with parentheses
  • Fuzzy search: ~word
  • Regex search: /pattern/ (advanced only)
  • Strong's numbers: G26, H430

Example complex query: "greatest of these" hope love ~50w NOT (peace AND despair)

This finds verses containing:

  • The exact phrase "greatest of these"
  • "hope" and "love" within 50 words of each other
  • NOT containing both "peace" AND "despair"

Constructors

Constructor

new SearchQueryParser(): SearchQueryParser

Returns

SearchQueryParser

Methods

extractPhrases()

extractPhrases(query): string[]

Defined in: Services/SearchQueryParser.ts:221

Extract all quoted phrases from a query

Parameters

query

string

Returns

string[]


getSuggestions()

getSuggestions(query): string[]

Defined in: Services/SearchQueryParser.ts:295

Get suggested corrections for common misspellings Useful for KJV's different spellings (neighbour vs neighbor, etc.)

Parameters

query

string

Returns

string[]


isReference()

isReference(query): boolean

Defined in: Services/SearchQueryParser.ts:246

Check if query is a Bible reference (for navigation vs search detection) Examples: "John 3:16", "Genesis 1", "Rom 8:28-30"

Returns true if it looks like a reference, false otherwise

Parameters

query

string

Returns

boolean


parse()

parse(query): ParsedQuery

Defined in: Services/SearchQueryParser.ts:28

Main parsing method Analyzes query and determines search type and components

Parameters

query

string

Returns

ParsedQuery


removePhrases()

removePhrases(query): string

Defined in: Services/SearchQueryParser.ts:236

Remove phrases from query (for extracting remaining terms)

Parameters

query

string

Returns

string


validate()

validate(query): string | undefined

Defined in: Services/SearchQueryParser.ts:256

Validate search query Returns error message if invalid, undefined if valid

Parameters

query

string

Returns

string | undefined