Repository navigation
Description
Summary
ArcadeDB's FULL_TEXT index currently ranks results with a simple term-coordination (match-count) model, not BM25. This proposes adding native BM25 (TF/IDF + document-length normalization) scoring to the full-text search path, so lexical relevance matches what users expect from Lucene/Elasticsearch/Solr/CrateDB.
Raised in discussion #4664 (enterprise hybrid-retrieval evaluation: vector + BM25/full-text + graph traversal for government/legal documents).
Current behavior
Lucene is used by ArcadeDB only for analyzers/tokenizers/stemmers and query-syntax parsing - not for the inverted-index storage or its scoring engine.
In LSMTreeFullTextIndex.get() the score for a record starts at 1 and is incremented by 1 for every matching query term:
// Accumulate score for this RID based on number of matching query terms
final AtomicInteger score = scoreMap.get(rid);
if (score == null)
scoreMap.put(rid, new AtomicInteger(1));
else
score.incrementAndGet();This means:
- No term frequency (TF) within a document
- No inverse document frequency (IDF)
- No document-length normalization
- No field boosts in the main scoring path
- No score explanation / explain API
So a document mentioning a rare, highly-discriminative term once ranks the same as (or below) a document that trivially matches more common query terms. This is fine for boolean filtering but inadequate for relevance-ranked retrieval.
Note: BM25-style scoring with IDF (Robertson-Sparck-Jones) does already exist in the LSM_SPARSE_VECTOR path (BlockMax-WAND DAAT), but it requires the user to generate sparse vectors externally. There is no native "index text -> BM25 ranking" in the full-text path.
Proposed work
-
BM25 similarity for
FULL_TEXT/SEARCH_INDEX(...)- Maintain the needed statistics: per-term document frequency (IDF), per-document term frequency (TF), per-document/field length and average length for normalization.
- Implement the standard BM25 formula with configurable
k1(default 1.2) andb(default 0.75). - Make it the default ranking model (with a compatibility switch to fall back to the legacy match-count score).
-
Field boosts applied to the scoring (per-field weight in multi-field full-text indexes).
-
Score explanation - optional
explainoutput describing how a score was computed (term contributions, IDF/TF/norm factors). -
Configuration via index metadata (alongside the existing analyzer/
defaultOperator/allowLeadingWildcardoptions): similarity model (BM25|CLASSIC),k1,b, per-field boosts. -
(Stretch) Auto text -> sparse-vector / unified hybrid index: index text and expose it directly to
vector.sparseNeighbors/vector.fusewithout external sparse-vector generation, so BM25 lexical + dense vector + graph traversal fuse in a single query path.
Why
- Closes the most-requested gap for accuracy-first hybrid retrieval (RAG, legal/government search).
- Brings full-text ranking in line with Lucene/Elasticsearch/Solr/CrateDB expectations.
- Composes cleanly with the existing
vector.fuse(...)(RRF/DBSF/LINEAR) hybrid pipeline and in-database graph traversal.
Acceptance criteria
- BM25 scoring available and default for full-text queries, with documented
k1/band a switch back to the classic model. - Field boosts honored in scoring.
- Optional score explanation output.
- Regression tests covering TF, IDF, length-normalization, field boosts, and backward-compatible classic mode.
- Documentation updated (full-text indexing + hybrid retrieval pages).
References
- Discussion: Any plan for BM25 and inverted index like lucene for Full text search? #4664
- Code:
engine/src/main/java/com/arcadedb/index/fulltext/LSMTreeFullTextIndex.java,FullTextQueryExecutor.java,engine/src/main/java/com/arcadedb/schema/FullTextIndexMetadata.java - Existing IDF reference implementation:
engine/src/main/java/com/arcadedb/index/sparsevector/PaginatedSparseVectorEngine.java(Robertson-Sparck-Jones IDF + BlockMax-WAND)
Activity
fix: [#4687] address review - per-bucket BM25 stats + tokens-only exp…
fix: [#4687] address review - thread-safe corpus counters + doc/comments
fix: [#4687] address review - unbiased per-bucket IDF, streaming scor…
fix: [#4687] address review - single-pass candidate scoring, similari…
fix: [#4687] address review - logging, marker guard, state reset, dri…
fix: [#4687] address review - double-precision scoring, restart stale…
fix: [#4687] address review - CAS staleness check, content-boost warn…
docs/test: [#4687] address review - phrase-boost & format-fragility n…
fix: [#4687] BM25 review batch - df deletion-marker guard, volatile f…
16 remaining items
docs: [#4687] BM25 review batch 18 - compaction/factory comments, get…
docs: [#4687] BM25 review batch 19 - fix executor thread-safety doc, …
fix: [#4687] BM25 review batch 20 - nested-negation exclusion, pure-n…
style: [#4687] BM25 review batch 21 - consistent pattern matching, EX…
perf: [#4687] BM25 review batch 22 - single-lookup token recording, p…
fix: [#4687] BM25 review batch 23 - drift WARNING threshold, same-tx …
test: [#4687] BM25 review batch 24 - guarantee compaction split, pin …
fix: [#4687] BM25 review batch 25 - open-time counter warning, reload…
fix: [#4687] BM25 review batch 26 - IndexInternal guard, safer key al…
feat: [#4687] native BM25 full-text scoring (field boosts, caret, EXP…
lvca commentedon Jun 24, 2026
Implemented, docs updated ;-)
lvca commentedon Jun 24, 2026
Native BM25 full-text scoring has landed (implemented in #4695, merged) and the documentation is updated.
What's in
FULL_TEXTindexes, replacing the legacy term-coordination (match-count) model. BM25 is the default for newly created indexes; existing indexes keepCLASSICuntil rebuilt, so upgrades are non-breaking on ranking.bm25_k1/bm25_b, and per-field boosts (<field>_boost) for multi-property indexes.term^N,field:term^N, group boosts), Lucene-style.EXPLAIN/PROFILEnow surface the scoring breakdown (similarity, k1/b, corpus stats, per-term df/idf/boost).withBM25(k1, b),withFieldBoost(field, boost),withSimilarity(...).SEARCH_INDEXis a first-class leg ofvector.fuse, so BM25 keyword relevance fuses with dense + sparse vectors (RRF) in one server-side query - the use case from Any plan for BM25 and inverted index like lucene for Full text search? #4664.contentproperty name colliding with the parser default field, andREBUILD INDEX * WITH ...silently dropping the first setting.Note
One behavior change for existing CLASSIC indexes:
$scoreis now a float (was anIntegermatch count). Read it as aNumber. See the release/upgrade notes for details.Examples
Create a BM25 index (default) and rank with
$score:Boost a single word with the Lucene caret (
^) - here "java" counts 3x more than "database":Tune parameters and add a per-field boost on a multi-property index:
Inspect the scoring with EXPLAIN:
Hybrid retrieval - fuse BM25 + dense + sparse with RRF (the #4664 pattern):
To switch an existing index to BM25, rebuild it (
REBUILD INDEX \Article[content]`); to repair/pre-warm the corpus counters without a full reindex, useREBUILD INDEX WITH statsOnly = true`.Thanks @sreekanthedayar for the detailed use case that drove this.
sreekanthedayar commentedon Jun 24, 2026
Well appreciated for this quick implementation. Need to build an adapter for ArcadeDB and test .
feat: [#4687] native BM25 full-text scoring (field boosts, caret, EXP…