GitHub

Full-text search for Svelte 5 apps

FTS5 / tsvector, trigram fuzzy matching, geo proximity, synonym expansion, query resolution, Polish locale support. Driven by your own database via a pluggable schema adapter.

pnpm add @nomideusz/svelte-search

1. Normalize & tokenize

normalize · trigrams · stripGeoIntent · stripStopWords · isPostcode
Normalized hatha w warszawie blisko mnie
After stripGeoIntent hatha w warszawie
After stripStopWords hatha warszawie
Geo intent yes
Postcode? no
Token count 2
Tokens
hathawarszawie
Trigrams (10)
hataththawararsrszszazawawiwie

2. Similarity

trigramSimilarity · levenshtein · levenshteinSimilarity
Trigram similarity
0.250 25%
Levenshtein distance 1 edit
Levenshtein similarity
0.800 80%

3. Geo helpers

haversineKm · walkingMinutes · boundingBox · formatDistance · formatWalkingTime
Haversine distance 252.35 km
formatDistance 252.4 km
Walking time 4101 min
formatWalkingTime 68 hr 21 min walk
Bounding box (for SQL pre-filter)
{
  minLat: 52.18408,
  maxLat: 52.27392,
  minLng: 20.93867,
  maxLng: 21.08533
}

4. Query resolver

parseQuery · classifies tokens into location / category / area / rest
Location warsaw matched "warszawie"
Category hatha matched "hatha"
Postal code
Geo intent no
Remaining tokens
mokotow
Raw ParsedQuery
{
  "normalized": "hatha w warszawie mokotow",
  "working": "hatha warszawie mokotow",
  "geoIntent": false,
  "location": {
    "matched": "warszawie",
    "slug": "warsaw",
    "original": "warszawie"
  },
  "category": {
    "matched": "hatha",
    "slug": "hatha",
    "original": "hatha"
  },
  "rest": [
    "mokotow"
  ]
}
Lookup data used in this demo
locationMap (14)

includes Polish locative forms — "warszawie" and "warszawa" both resolve to warsaw.

categoryMap (8)

yoga styles: hatha, vinyasa, yin, ashtanga, kundalini, power, restorative, nidra.

areaMap (6 locations)

districts per city — e.g. Warsaw: mokotow, praga, wola, ochota, śródmieście.

Ready to wire it up to your DB? See the docs for the full SchemaAdapter contract.