Repository navigation
Description
Is there an existing issue for the same feature request?
- I have checked the existing issues.
Is your feature request related to a problem?
WAND — the algorithm
WAND = Weak AND (a.k.a. Weighted AND). It's a document-at-a-time (DAAT) top-K retrieval algorithm — the standard fast way to answer "give me the K highest-BM25-scoring documents for this multi-term query" without scoring every matching document. Introduced by Broder et al. (2003); the Block-Max WAND (BMW) refinement is Ding & Suel (2011). It is what the retrieval fulltext index uses.
The problem it solves
A query like MATCH(txt) AGAINST('red apple banana') is an OR over terms: a document matches if it contains any term, and its rank is score(d) = Σ_t score(t, d) (BM25 per term). The naive plan scores every document containing any query term, then sorts and takes the top-K. On a large corpus with common terms, that scores most of the collection — and you only wanted K rows. WAND skips the documents that provably cannot enter the top-K.
The core idea: a threshold + upper bounds
Two ingredients:
-
A running threshold
θ= the K-th best score seen so far (the smallest score currently in a size-K min-heap). A document can only matter if its score can beatθ. -
A per-term score upper bound
UB(t)= the maximum score termtcan contribute to any document (precomputed from its posting list — for BM25, roughlyidf(t) × max-tf-component). Then for any documentd:score(d) ≤ Σ_{t ∈ query, t ∈ d} UB(t)
If that upper bound < θ, the document cannot reach the top-K → skip it, never score it.
The mechanism: pivoting over sorted cursors
Each query term keeps a cursor over its posting list (posting lists are sorted by doc id). One DAAT step:
- Sort the cursors by their current doc id (ascending).
- Find the pivot. Walk the cursors in doc-id order, accumulating
UB(t). The first term at which the running sum exceedsθis the pivot term; its current doc id is the pivot doc — the smallest doc id whose upper bound could possibly beatθ(everything before it has too few high-value terms). - Act on the pivot:
- If every cursor before the pivot is already at the pivot doc → all those terms are present in the pivot doc → fully score it; if its real score >
θ, push it into the heap and raiseθ. - Otherwise → the lagging cursors are on smaller doc ids that cannot win, so advance them forward to (at least) the pivot doc — jumping over a whole run of hopeless documents.
- If every cursor before the pivot is already at the pivot doc → all those terms are present in the pivot doc → fully score it; if its real score >
As the heap fills, θ rises monotonically, which makes the upper-bound test stricter, which makes the pivot jumps larger — the search accelerates as it goes. Only the documents that could plausibly enter the top-K are ever fully scored.
Block-Max WAND (the refinement in use)
A single global UB(t) is loose — one outlier posting inflates it everywhere. BMW divides each posting list into blocks and stores a max score per block. The pivot test then uses the block-local max for each cursor's current region, giving a much tighter upper bound → more aggressive skipping, and it can skip whole blocks at once. (In the index, this is the per-block metadata finalizeScoring computes alongside the postings.)
Why it is both fast and correct
- Exact, not approximate. WAND/BMW only skips a document when its upper bound is below
θ. Since the upper bound ≥ the true score, a skipped document truly could not have entered the top-K — the returned top-K is identical to the exhaustive-scoring result. (This is why the gold correctness test diff-checks WAND's top-K against a brute-forceΣ tf·idf²reference.) - Fast because it evaluates a small fraction of the OR-matching documents — the win grows with corpus size and with how selective K is.
How it maps to the MO retrieval index
- Storage = the postings (
docID,tf) per term + docmap (pk, doc length) + per-block max scores, serialized into the tag=0 base sub-indexes (and tag=1 tail deltas). BM25 needs corpus statsN(doc count) andavgdl(average doc length), precomputed at load. - Query = the pushed-down top-K (
LIMIT k→ heap size K), an optional membership bitmap (theWHEREprefilter, AND-ed into the walk so filtered-out docs are skipped like non-matches), and the multi-segment liveness bitmap (deletes/updates). The engine runs the BMW walk over the live, filtered postings and returns the exact BM25 top-K directly — no SQL SORT node.
In one line
WAND is a safe top-K pruning strategy — keep a threshold of the current K-th best score, bound each candidate by the sum of its terms' max possible contributions, and skip every document whose bound cannot beat the threshold — so you score only the handful of documents that could actually win.
References
- A. Z. Broder, D. Carmel, M. Herscovici, A. Soffer, J. Zien. Efficient Query Evaluation using a Two-Level Retrieval Process. CIKM 2003. (original WAND)
- S. Ding, T. Suel. Faster Top-k Document Retrieval Using Block-Max Indexes. SIGIR 2011. (Block-Max WAND)
Describe the feature you'd like
Describe implementation you've considered
No response
Documentation, Adoption, Use Case, Migration Strategy
Additional information
No response
Activity
[-][Feature Request]: WAND-based retrieval fulltext index — BM25 top-K retrieval without full-scan + SORT[/-][+][Feature Request]: WAND-based retrieval index — BM25 top-K retrieval without full-scan[/+]feat: `fulltext2` — complete rewrite of fulltext index and add a posi…
cpegeric commentedon Aug 17, 2026
please verify
XuPeng-SH commentedon Aug 22, 2026
@cpegeric Please pass these issues to QA for testing going forward.
[4.2] feat: backport FULLTEXT2 from main (#27663)
VioletQwQ-0 commentedon Aug 27, 2026
更正(2026-09-24):此评论为历史记录,原 freetier-01 / 两小时运行门槛不适用于本次 main WAND 验收。请以最新转测说明为准。
自动化 QA handoff:PR #27663 已合并。
325686d29c17b3729f32b837b5bc2144d33f0a9b,merge commit03ffd507597ded14abbce44c31616e5979463096,合并时间2026-08-27T05:34:32Z。mainhead:b0ae66c04d9a67175d2dfb8bf1c777fb888e1430。registry-1.docker.io的 BuildKit manifest 返回 EOF,因此后续 TKE 环境测试未开始,不能据此宣称产品验收通过。freetier-01;先执行唯一数据库、小语料、15 分钟 FULLTEXT2 shakeout,再由完整观测解锁低负载两小时 continuous run。Ariznawlll。Issue 已保持 OPEN,并添加
phase/testing;请 QA 完成上述门禁后明确回复 PASS 或 FAIL。7 remaining items
slyunnn commentedon Sep 28, 2026
WAND QA acceptance run (attempt
1)codex/issue25541-wand-qa/e00074d098f7ab37fda1bee67cb2ce94366e16c3main@95b1d2bfd9d756d08320569858080cb16f230fffResults:
INCONCLUSIVE— fixed-commit WAND mechanism gate did not reach the assertions. Its native dependency build failed becauseCC=clangwas configured butclangwas unavailable on the runner, so the required WAND/block-max evidence was not produced.NOT_RUN— the real TKE SQL, update/delete/insert, two-CN, and CN-reload phase was gated by the mechanism failure and was not started.INCONCLUSIVE— cleanup collected no complete CBS ownership ledger: it expected three run-owned LogService disk identities but none were available. The test namespace was absent, but this alone is not sufficient evidence to mark storage cleanup complete.Final acceptance result:
INCONCLUSIVE. This run is an execution/control-environment blocker, not evidence of a WAND product failure or a pass. The issue remains in testing; after the runner toolchain and cleanup-evidence gate are corrected, rerun the same pinned workflow and record the three phase results before making a final conclusion.VioletQwQ-0 commentedon Sep 28, 2026
更新(2026-09-29):本评论的控制 head
e2be0625...已过期。第二次 QA 运行仍为INCONCLUSIVE;请以最新跟进为准。新 head0e1cecabc12ac5a9b82973d4e8304ee95a576bab已修补镜像身份采集,缺少 CBS 核验凭据时请勿触发 TKE 运行。@slyunnn 已处理 QA 第 1 次运行 的验收包问题。该次运行的结论保持
INCONCLUSIVE:机制 job 因 runner 没有配置的 clang 而未到达 WAND 断言;真实 TKE SQL / 增删改 / CN 重载为NOT_RUN;清理 job 在从未部署的情况下仍要求三块 CBS 磁盘清单。本次没有 WAND 产品 PASS 或 FAIL 证据。修复已推到验收包 PR #1738,新的控制 head 为
e2be06253ec3b8dc8fc33560b5933a751de75313:actionlint、workflow graph 和 control contracts 通过;新 head 的 Linux contracts 与 validate 均通过。新 head 尚无 TKE 运行,Linux 机制测试仍需本次重跑验证。请从
codex/issue25541-wand-qa再次单独触发Test_list=fulltext2_wand_qa,仍使用Repo=matrixorigin/matrixone、Branch=main、Commit_Id=95b1d2bfd9d756d08320569858080cb16f230fff。运行后先核对 ActionsheadSha为上述新控制 SHA,再检查机制、SQL/CN 重载、清理三组 artifacts 并回填逐项结果。此前转测评论中的控制 SHAe00074d...是第 1 次运行的历史版本,请勿用于下一次验收。Issue 继续保持
OPEN/phase/testing,待 QA 给出固定版本和环境上的实际终态结果。slyunnn commentedon Sep 29, 2026
@VioletQwQ-0
WAND QA acceptance run (attempt
1, rerun)codex/issue25541-wand-qa/e2be06253ec3b8dc8fc33560b5933a751de75313main@95b1d2bfd9d756d08320569858080cb16f230fffResults after inspecting
wand-qa-mechanism-*,wand-qa-tke-*,wand-qa-cleanup-*, and the final summary artifact:PASS— the fixed-commit mechanism phase selectedGCC 13.3.0; the tokenizer fixture, WAND/Block-Max observations for build and loaded paths, independent PK/score oracle, tie oracle, and tail-liveness passed. The forced full-evaluator negative control failed as intended.INCONCLUSIVE— TKE created the isolated namespace and reached eight Ready pods, but identity verification stopped atofficial image mismatch in nightly-regression-dis-dn-0. The artifact does not retain the observed PodimageIDor/mo-service -versionbefore the assertion, so the required runtime identity cannot be independently established. SQL, update/delete/insert, direct-CN, and CN-reload checks were therefore not run.INCONCLUSIVE— the exact-owner finalizer removed the namespace and MatrixOneCluster, and captured six run-owned PV identities; however, the independent CBS deletion verification could not run because the cloud CBS credential required by that check was unavailable. Storage cleanup is not accepted as complete without that evidence.The wrapper summary reports
mechanism=PASS,tke=FAIL,cleanup=INCONCLUSIVE, andoverall=FAIL. Per the acceptance classification, this is not a WAND SQL/productFAIL: the TKE identity evidence is insufficient and the SQL/CN-reload phase isNOT_RUN. Final QA conclusion:INCONCLUSIVE.Follow-up required before another acceptance run: make the deployment consume the pinned amd64 image digest (rather than relying on a mutable tag with
IfNotPresent), record the expected and observed Pod image IDs plus binary version before any identity assertion, and provide the CBS verification credential or an approved equivalent independent deletion proof. Keep the issueOPEN/phase/testing.VioletQwQ-0 commentedon Sep 29, 2026
@slyunnn 已检查本次 QA rerun 36403896142 的 artifacts,接受本次结论
INCONCLUSIVE。固定版本的 Linux WAND / Block-Max 机制证据为PASS;TKE 虽达到八个 Ready Pod,但身份检查未保存实际 imageID / 二进制版本便中止,SQL、增删改和 CN 重载均为NOT_RUN。Namespace / MatrixOneCluster 已由 finalizer 删除,但缺少 CBS 云 API 的独立删除证明,不能判清理完成。这不是 WAND SQL 产品FAIL,也不是验收PASS。验收包 Draft PR #1738 已更新至控制 head
0e1cecabc12ac5a9b82973d4e8304ee95a576bab:四类 MO 组件及 init 容器固定使用官方 amd64 digest,拉取策略为Always;身份断言前归档每个 Pod 的预期/实际 imageID 和/mo-service -version;缺少 CBS 核验凭据时,在创建集群前停止并记为BLOCKED_ENVIRONMENT。本地 21 项测试、actionlint、workflow graph / contracts 和 diff 检查通过;新 head 的 PR CI 仍在运行。此修补尚无新的 TKE SQL / CN 重载结果。下一次 QA 运行的前提是由仓库/环境管理员安全配置
TKE_SECRET_ID、TKE_SECRET_KEY,并确保具备 CBSDescribeDisks权限,或先落实经 QA 认可的等价独立删除证明。现在请勿盲目重跑:当前缺凭据时新流程会在部署前阻断。凭据就绪后仍按原固定 MatrixOne commit95b1d2bfd9d756d08320569858080cb16f230fff和Test_list=fulltext2_wand_qa触发,并核对控制 head 与三组 artifacts。Issue 保持OPEN/phase/testing,等待正式 SQL、索引更新、重载与清理证据。