Repository navigation
fix(search): sort _doc in arrival order, not lexicographic _id order - #1127
Conversation
|
Thanks for this contribution — we'd like to merge it. Before we can, we need a signed Contributor License Agreement from: @Ravandevil25 It is a one-time thing per contributor, not per pull request. Read CLA.md, then open a small pull request adding your GitHub username to Once it is merged, comment |
There was a problem hiding this comment.
Reviewed — this is the right fix, and thank you for the test + CHANGELOG entry.
_docas arrival order matches the ES 8.x definition (index order), and the old arm madesort:[{"_doc":{}}]rank lexicographically by the_idstring, which was wrong on the wire.- Projecting
seq_noas a Number is the clean choice: unique per live doc (no tie-break ambiguity), and it pages throughsearch_afteron the existing numeric cursor path. - The
None => Value::Nullarm for the concurrent-tombstone race (missing policy governs) matchesmeta_sort_value's convention. Good catch.
One thing blocks merge, and it is paperwork, not code: the CLA check (verification/cla-signed) is failing — the merge gate requires a signed CLA for code contributions. Please sign it through the link the bot posted (or xerj.org/cla), and this merges as-is once CI runs. No further changes requested.
|
@cla-bot check |
|
Re-checking the CLA status for every commit author on this pull request… |
|
Thanks for this — the arrival-order intent is right and we'd like to land it. Two things block the merge:
If the CLA is a problem for you, tell us — the change is small enough that we can re-implement it with credit to you in the changelog instead. |
|
Re-checking the CLA status for every commit author on this pull request… |
Motivation: ES defines _doc as index (arrival) order — Lucene internal doc-id order. compute_sort_values projected the _id STRING as the _doc sort value, so sort:["_doc"] ranked lexicographically by _id: docs inserted zeta, alpha, mike came back alpha, mike, zeta — matching neither ES nor xerj's own stored order (LOSS_BATTLE_PLAN.md tracks this as the sort:["_doc"] _id-string defect, its own ticket). Root cause: engine/crates/xerj-engine/src/index.rs compute_sort_values shared one arm for _doc and _id (is_doc_order() || field == "_id"), emitting Value::String(id). Every consumer — SortTopK admission, final_hits ordering, cross-index merge, search_after cursor compare — then ranked on id strings via compare_sort_keys. Fix: _doc gets its own arm projecting the doc's seq_no (arrival sequence, unique per live doc) as a Number — numeric arrival order, no ties, and the emitted sort value pages as a search_after cursor through the existing numeric path unchanged. Unresolvable docs (concurrent tombstone between collect and key computation) yield Null so the request's missing policy governs, the meta_sort_value convention. _id sort still echoes the id string; the 340_flattened index.sort case is unaffected (API layer rewrites lone _doc to a field sort pre-engine). Evidence: engine/crates/xerj-engine/tests/sort_doc_is_arrival_order.rs watched FAIL before (lexicographic page on memtable + flushed paths) and PASS after; xerj-engine lib 732 passed; sort-adjacent suites (sort_on_meta_fields, sort_on_unresolvable_field, tied_score_resorts) green. ES-YAML gate + live ES A/B not run in this session (no server available) — flagged in PR body as Not-run.
d6632e2 to
13470dc
Compare
Fifth daily release cut. The window was dominated by the xerj-org#1109 security audit fixes and the config/telemetry honesty items, plus the first code contribution from a third external contributor. Window (v1.0.0-rc.85..main, PRs all cited in the CHANGELOG): - Security: xerj-org#1109 closed by PR xerj-org#1194 (audit remediation, Security section added to the notes) - Fixed: xerj-org#1158 (build-time half, PR xerj-org#1185, stays open on the issue), xerj-org#1189 + xerj-org#1190 (PR xerj-org#1193), xerj-org#1186 (PR xerj-org#1188), xerj-org#1146 (PR xerj-org#1177) and xerj-org#1092 (PR xerj-org#1184) - both Vincenzo Lombardo, xerj-org#1146 his first merged fix; _doc arrival order (xerj-org#1127, Saurav Kumar, his first code contribution) - Field reports: xerj-org#1178 (Vinz2168), xerj-org#1187 (thomas-villani) - Metrics chore 15b62f5 cited as a Community line (direct commit, [skip ci], rc.85 precedent) Roll mechanics: - engine/Cargo.toml workspace version 1.0.0-rc.86; Cargo.lock regenerated (version-only diff verified: 0 non-version lines) - CHANGELOG: fresh [Unreleased], rc.86 section, new Community section - ROADMAP: Last-reviewed pass for the cut (docs_capability_lists gate requires it), rc.86 paragraph in Next release, Open defects shortlist rolled to the eleven live trackers - landing footers: V1.0.0-RC.85 -> V1.0.0-RC.86 (91), lowercase variant (1); zero rc.85 patterns remain - release-notes-gate.sh run locally before this commit: PASS on freshness, issue-state (11 open-defect checks, 6 Fixed checks incl. the xerj-org#1158 stays-open marker) and coverage (9 window PRs) In flight past the cut: phase-B bulk coalescing for xerj-org#1147 (PR xerj-org#1195, sticky-failure fix + 8-in-flight wire concurrency, rustsec 10.1s->9.7s / pysec 17.4s->16.9s vs rc.85 on the loopback A/B), merges into the rc.87 window.
An agent wrote this; my operator (Saurav Kumar) reviewed and pushed it.
sort:[{"_doc": ...}]ranked lexicographically by_idinstead of ES index (arrival) order: docs insertedzeta, alpha, mikecame backalpha, mike, zeta. Root cause:compute_sort_values(engine/crates/xerj-engine/src/index.rs) shared one arm for_docand_id, projecting the id string — soSortTopKadmission, final ordering, cross-index merge andsearch_afterall ranked on id strings. The fix gives_docits own arm projecting the doc'sseq_noas a Number (numeric arrival order, unique per live doc, pages as a cursor);_idsort still echoes the id string. Seedemo/playbooks/LOSS_BATTLE_PLAN.mdout-of-scope list for the ticket this closes.Verified (commands run, output observed):
cargo test -p xerj-engine --test sort_doc_is_arrival_order: FAILED before (lexicographic page, memtable + flushed), PASSED after (2/2)cargo test -p xerj-engine --lib: 732 passed, 0 failedsort_on_meta_fields,sort_on_unresolvable_field,tied_score_resorts: all greencargo fmt -p xerj-enginecleanAssumed (not run, flagged honestly):
_doc= index order); no live ES 8.13.4 A/B in this session0 failed) not run — no server on this machine; the only YAML pinningsort: _doc(search/340_flattened.yml, anindex.sortindex rewritten to a field sort pre-engine) is unaffected by inspectionNot run: scoped release build,
scripts/benchharnesses.