mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-21 02:28:07 +02:00
test(engine): full rank-order goldens for nearest + bm25 (gap #2)
Existing search tests stopped at top-1 (nearest) or non-empty (bm25), so a regression corrupting ranks 2..k or reversing the sort direction passed CI silently. Pin the FULL ordered slug list: nearest([0.1,0.2,0.3,0.4]) -> [ml-intro, nlp-guide, rl-intro] (ml-intro exact at dist 0, rest by ascending L2); bm25(Learning) -> [rl-intro, ml-intro, dl-basics] (descending score). nearest/bm25 skip apply_ordering (is_search_ordered) and return Lance native order, so result_slugs row order == rank order; values resolved by running and confirmed stable across runs.
This commit is contained in:
parent
2e2d2e9ba0
commit
e2784cad58
1 changed files with 38 additions and 0 deletions
|
|
@ -556,6 +556,44 @@ async fn bm25_returns_ranked_results() {
|
|||
assert!(result.num_rows() <= 3, "bm25 should respect limit 3");
|
||||
}
|
||||
|
||||
// Full rank-ORDER golden (not just top-1 / non-empty): pins ranks 2..k so a
|
||||
// regression corrupting the tail or reversing the sort direction fails loudly.
|
||||
// nearest skips apply_ordering (is_search_ordered) and returns Lance native
|
||||
// order, so result_slugs row order == rank order.
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn nearest_full_rank_order() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mut db = init_search_db(&dir).await;
|
||||
let result = query_main(
|
||||
&mut db,
|
||||
SEARCH_QUERIES,
|
||||
"vector_search",
|
||||
&vector_param("$q", &[0.1, 0.2, 0.3, 0.4]),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
// [0.1,0.2,0.3,0.4] == ml-intro's embedding (dist 0); the rest by ascending L2.
|
||||
assert_eq!(result_slugs(&result), vec!["ml-intro", "nlp-guide", "rl-intro"]);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn bm25_full_rank_order() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mut db = init_search_db(&dir).await;
|
||||
let result = query_main(
|
||||
&mut db,
|
||||
SEARCH_QUERIES,
|
||||
"bm25_search",
|
||||
¶ms(&[("$q", "Learning")]),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
// Descending BM25 score order.
|
||||
assert_eq!(result_slugs(&result), vec!["rl-intro", "ml-intro", "dl-basics"]);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn mutation_commit_refreshes_search_indices_without_manual_ensure() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue