Skip to content

feat: full-text BM25 search (1:1 with surql-rs 0.29.0)#71

Merged
albedosehen merged 1 commit into
mainfrom
feat/fulltext-bm25
Jun 17, 2026
Merged

feat: full-text BM25 search (1:1 with surql-rs 0.29.0)#71
albedosehen merged 1 commit into
mainfrom
feat/fulltext-bm25

Conversation

@albedosehen

Copy link
Copy Markdown
Collaborator

Ports the full-text BM25 feature to parity with the sibling libraries (surql-rs v0.29.0, surql-py, surql-go).

Added: DEFINE ANALYZER builder (analyzer/standardAnalyzer, Tokenizer/TokenFilter); BM25 FULLTEXT index (bm25Index, searchIndex(..., {bm25,highlights})); full-text query builder (fulltextSearch/searchScore + fulltextSearchQuery); generateAnalyzerSql.
Fixed: SurrealDB 3.x renamed the full-text index keyword SEARCHFULLTEXT (the old form was a parse error on v3); parser accepts both. See docs/v3-patterns.md.

Version 1.5.0 → 1.6.0. Gates: deno check/deno lint clean; deno task test green (one pre-existing live-DB CLI test excepted). No release in this PR.

… index + fulltextSearch)

Port the surql-rs v0.29.0 full-text search feature 1:1.

Added:
- src/schema/analyzer.ts: DEFINE ANALYZER builder (AnalyzerDefinition,
  Tokenizer, TokenFilter, edgeNgram/ngram/snowball, analyzer/standardAnalyzer,
  analyzerToSurql, validateAnalyzer) in the repo's frozen-immutable idiom.
- bm25Index() convenience and bm25/highlights options on searchIndex();
  IndexDefinition gains bm25?/highlights? and an optional analyzer.
- generateAnalyzerSql() and an analyzers[] input to generateSchemaSql() that
  emits DEFINE ANALYZER ahead of the tables that reference it.
- Query.fulltextSearch(field, reference, query) + Query.searchScore(reference,
  alias) + the fulltextSearchQuery() helper. Query text is inlined as a
  single-quoted, escaped literal (backslash then quote).

Fixed:
- Full-text index now emits the SurrealDB 3.x FULLTEXT keyword (was SEARCH,
  a v3 parse error) with `FULLTEXT ANALYZER <analyzer|ascii> [BM25] [HIGHLIGHTS]`
  in both generateTableSql/generateEdgeSql (sql.ts) and the migration differ
  (diff.ts). The INFO FOR TABLE parser recognises both spellings and normalises
  the historical `ascii` analyzer back to undefined so default-form indexes
  round-trip.

Docs/version:
- docs/v3-patterns.md gains a FULLTEXT/BM25 section (SEARCH->FULLTEXT rename;
  search::score returns 0 under the v3 streaming executor, so rank by scan
  order for RRF). README feature list updated.
- CHANGELOG 1.6.0 entry; version bumped to 1.6.0 in deno.json (npm version is
  sourced from deno.json at build time).

Gates: deno fmt (LF/CI-clean), deno lint (169 files), deno check, and
deno task test (206 passed / 1782 steps; the single live-DB CLI failure is
pre-existing and environment-dependent).
@albedosehen albedosehen merged commit 6b54412 into main Jun 17, 2026
10 of 12 checks passed
@albedosehen albedosehen deleted the feat/fulltext-bm25 branch June 17, 2026 22:16
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