Projects BibleWeb Search Multi-word fuzzy fallback
Needs Design

Multi-word fuzzy fallback

Area: Search

Context

Problem: When users search for a multi-word phrase that doesn't exist verbatim in the Bible, they get zero results. A smarter system would fall back to searching for individual words.

Solution: If a phrase search returns no results, automatically fall back to searching for each word individually and combine the results.

Not included: Edit-distance fuzzy matching or "did you mean?" suggestions.

Functional

Expected behavior:

  1. User searches "eternal life in heaven"
  2. FTS5 finds no exact phrase match
  3. System automatically retries with individual words: "eternal" AND "life" AND "in" AND "heaven"
  4. Results appear with a note explaining the fallback

TODO: Define the fallback UX — should results show automatically or ask the user?

UX & Design

TODO: Design feedback for when fallback occurs (e.g., "No exact match. Showing results for individual words.")

Technical

Implementation:

  • First query: phrase search (current behavior)
  • If zero results: split into individual words, search each
  • Combine and rank results (verses matching more words ranked higher)

Reference: BibleGame fell back to individual word search when phrase found nothing.

Files:

  • apps/web/src/lib/server/queries/search.ts (modify)

Status

Current: NEEDS_DESIGN Milestone: Foundation Priority: Low — edge case improvement

Design questions:

  1. Should fallback happen automatically or ask the user?
  2. How to rank results when falling back (by word count match)?
  3. Should stop words be excluded from individual word searches?

Dependencies:

  • Requires: full-text search (DONE)