Skip to content

feat: add Hebrew proximity wildcard search - #521

Open
david-hoze wants to merge 4 commits into
scambier:masterfrom
david-hoze:proximity-wildcard-search
Open

feat: add Hebrew proximity wildcard search#521
david-hoze wants to merge 4 commits into
scambier:masterfrom
david-hoze:proximity-wildcard-search

Conversation

@david-hoze

Copy link
Copy Markdown

Summary

  • Adds a new @N(pattern1 pattern2 ...) search syntax that finds Hebrew words matching wildcard patterns within N words of each other (N is optional, defaults to 10)
  • Supports * (any Hebrew letter), + (prefix/suffix letter set), final-form interchangeability (e.g. מ/ם, נ/ן), and automatic nikud stripping
  • Scans all indexed documents directly for proximity queries, bypassing MiniSearch pre-filtering (Hebrew prefix letters make token-based pre-filtering unreliable)
  • Handles both LTR (@10(תקון)) and RTL ()10(תקון@) input forms

Files changed

File Action
src/search/proximity-search.ts Created — core proximity search logic (parsing, regex compilation, tokenizer, proximity window finder, match conversion)
src/search/query.ts Modified — detect @N(...) syntax early in the Query constructor, store parsed ProximityQuery, populate root terms for downstream use
src/search/search-engine.ts Modified — added getProximitySuggestions() that scans all indexed documents with proximity matching, called from getSuggestions() when a proximity query is detected
src/__tests__/proximity-search-tests.ts Created — unit tests for parsing, regex compilation, tokenization, proximity matching, and root term extraction

Test plan

  • Open Omnisearch (Vault search) and enter @10(תקון) — should return notes containing the Hebrew word תקון (and variants like תִּקּוּן with nikud)
  • Verify highlighting works on matched words in the result excerpts
  • Test multi-pattern query @10(+ת*ק*ן+ +ש+למ+ מאד) — should find documents where all three patterns appear within 10 Hebrew words of each other
  • Test single-pattern query @(+תקן+) (no distance number) — should default to distance 10
  • Test RTL input form )10(תקון@ — should be recognized and work identically
  • Verify that normal (non-proximity) searches are completely unaffected
  • Run existing test suite to confirm no regressions

david-hoze and others added 4 commits February 16, 2026 22:38
- Strip Hebrew nikud (U+0591-U+05C7) and optional Arabic harakat in removeDiacritics
- Use query terms for highlighting instead of MiniSearch result.terms (avoids fuzzy false highlights)
- Disable fuzziness for terms length <= 4 to avoid e.g. ׳×׳§׳™׳© matching ׳×׳§׳•׳�
- When ignore diacritics: match on original text with optional-diacritics regex so highlight indices and spans are correct (was using normalized-text indices on original, causing wrong highlights)

Co-authored-by: Cursor <cursoragent@cursor.com>
…in diacritics regex

Co-authored-by: Cursor <cursoragent@cursor.com>
New search syntax finds Hebrew words matching wildcard patterns within N words of each other. Supports star and plus wildcards, final-form interchangeability, and nikud stripping. Bypasses MiniSearch for proximity queries to handle Hebrew prefix letters correctly. Accepts both LTR and RTL input forms, and optional N defaults to 10.

Co-authored-by: Cursor <cursoragent@cursor.com>
Wildcards at leading/trailing positions (e.g. +׳©׳�׳�+) only apply at the edges. Only wildcards between the first and last Hebrew letter trigger middle expansion between all letter pairs (e.g. +׳©+׳�׳�+). Updated tests to verify both behaviors.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant