mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-31 15:31:53 +08:00
snapshot the scores side by side with the score details
This commit is contained in:
parent
2c3af8e513
commit
6079141ea6
@ -10,7 +10,7 @@ use maplit::hashset;
|
|||||||
use meili_snap::snapshot;
|
use meili_snap::snapshot;
|
||||||
|
|
||||||
use crate::index::tests::TempIndex;
|
use crate::index::tests::TempIndex;
|
||||||
use crate::score_details::ScoringStrategy;
|
use crate::score_details::{ScoreDetails, ScoringStrategy};
|
||||||
use crate::{Criterion, Filter, Search, TimeBudget};
|
use crate::{Criterion, Filter, Search, TimeBudget};
|
||||||
|
|
||||||
fn create_index() -> TempIndex {
|
fn create_index() -> TempIndex {
|
||||||
@ -88,6 +88,7 @@ fn degraded_search_cannot_skip_filter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::format_collect)] // the test is already quite big
|
||||||
fn degraded_search_and_score_details() {
|
fn degraded_search_and_score_details() {
|
||||||
let index = create_index();
|
let index = create_index();
|
||||||
let rtxn = index.read_txn().unwrap();
|
let rtxn = index.read_txn().unwrap();
|
||||||
@ -99,13 +100,10 @@ fn degraded_search_and_score_details() {
|
|||||||
search.time_budget(TimeBudget::max());
|
search.time_budget(TimeBudget::max());
|
||||||
|
|
||||||
let result = search.execute().unwrap();
|
let result = search.execute().unwrap();
|
||||||
snapshot!(format!("{:#?}\n{:#?}", result.documents_ids, result.document_scores), @r###"
|
snapshot!(format!("IDs: {:?}\nScores: {}\nScore Details:\n{:#?}", result.documents_ids, result.document_scores.iter().map(|scores| format!("{:.4} ", ScoreDetails::global_score(scores.iter()))).collect::<String>(), result.document_scores), @r###"
|
||||||
[
|
IDs: [4, 1, 0, 3]
|
||||||
4,
|
Scores: 1.0000 0.9167 0.8333 0.6667
|
||||||
1,
|
Score Details:
|
||||||
0,
|
|
||||||
3,
|
|
||||||
]
|
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
Words(
|
Words(
|
||||||
@ -170,13 +168,10 @@ fn degraded_search_and_score_details() {
|
|||||||
search.time_budget(TimeBudget::max().with_stop_after(1));
|
search.time_budget(TimeBudget::max().with_stop_after(1));
|
||||||
|
|
||||||
let result = search.execute().unwrap();
|
let result = search.execute().unwrap();
|
||||||
snapshot!(format!("{:#?}\n{:#?}", result.documents_ids, result.document_scores), @r###"
|
snapshot!(format!("IDs: {:?}\nScores: {}\nScore Details:\n{:#?}", result.documents_ids, result.document_scores.iter().map(|scores| format!("{:.4} ", ScoreDetails::global_score(scores.iter()))).collect::<String>(), result.document_scores), @r###"
|
||||||
[
|
IDs: [0, 1, 4, 2]
|
||||||
0,
|
Scores: 0.6667 0.6667 0.6667 0.0000
|
||||||
1,
|
Score Details:
|
||||||
4,
|
|
||||||
2,
|
|
||||||
]
|
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
Words(
|
Words(
|
||||||
@ -215,13 +210,10 @@ fn degraded_search_and_score_details() {
|
|||||||
search.time_budget(TimeBudget::max().with_stop_after(2));
|
search.time_budget(TimeBudget::max().with_stop_after(2));
|
||||||
|
|
||||||
let result = search.execute().unwrap();
|
let result = search.execute().unwrap();
|
||||||
snapshot!(format!("{:#?}\n{:#?}", result.documents_ids, result.document_scores), @r###"
|
snapshot!(format!("IDs: {:?}\nScores: {}\nScore Details:\n{:#?}", result.documents_ids, result.document_scores.iter().map(|scores| format!("{:.4} ", ScoreDetails::global_score(scores.iter()))).collect::<String>(), result.document_scores), @r###"
|
||||||
[
|
IDs: [4, 0, 1, 2]
|
||||||
4,
|
Scores: 1.0000 0.6667 0.6667 0.0000
|
||||||
0,
|
Score Details:
|
||||||
1,
|
|
||||||
2,
|
|
||||||
]
|
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
Words(
|
Words(
|
||||||
@ -265,13 +257,10 @@ fn degraded_search_and_score_details() {
|
|||||||
search.time_budget(TimeBudget::max().with_stop_after(3));
|
search.time_budget(TimeBudget::max().with_stop_after(3));
|
||||||
|
|
||||||
let result = search.execute().unwrap();
|
let result = search.execute().unwrap();
|
||||||
snapshot!(format!("{:#?}\n{:#?}", result.documents_ids, result.document_scores), @r###"
|
snapshot!(format!("IDs: {:?}\nScores: {}\nScore Details:\n{:#?}", result.documents_ids, result.document_scores.iter().map(|scores| format!("{:.4} ", ScoreDetails::global_score(scores.iter()))).collect::<String>(), result.document_scores), @r###"
|
||||||
[
|
IDs: [4, 1, 0, 2]
|
||||||
4,
|
Scores: 1.0000 0.9167 0.6667 0.0000
|
||||||
1,
|
Score Details:
|
||||||
0,
|
|
||||||
2,
|
|
||||||
]
|
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
Words(
|
Words(
|
||||||
@ -321,13 +310,10 @@ fn degraded_search_and_score_details() {
|
|||||||
search.time_budget(TimeBudget::max().with_stop_after(4));
|
search.time_budget(TimeBudget::max().with_stop_after(4));
|
||||||
|
|
||||||
let result = search.execute().unwrap();
|
let result = search.execute().unwrap();
|
||||||
snapshot!(format!("{:#?}\n{:#?}", result.documents_ids, result.document_scores), @r###"
|
snapshot!(format!("IDs: {:?}\nScores: {}\nScore Details:\n{:#?}", result.documents_ids, result.document_scores.iter().map(|scores| format!("{:.4} ", ScoreDetails::global_score(scores.iter()))).collect::<String>(), result.document_scores), @r###"
|
||||||
[
|
IDs: [4, 1, 0, 2]
|
||||||
4,
|
Scores: 1.0000 0.9167 0.8333 0.0000
|
||||||
1,
|
Score Details:
|
||||||
0,
|
|
||||||
2,
|
|
||||||
]
|
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
Words(
|
Words(
|
||||||
@ -382,13 +368,10 @@ fn degraded_search_and_score_details() {
|
|||||||
search.time_budget(TimeBudget::max().with_stop_after(6));
|
search.time_budget(TimeBudget::max().with_stop_after(6));
|
||||||
|
|
||||||
let result = search.execute().unwrap();
|
let result = search.execute().unwrap();
|
||||||
snapshot!(format!("{:#?}\n{:#?}", result.documents_ids, result.document_scores), @r###"
|
snapshot!(format!("IDs: {:?}\nScores: {}\nScore Details:\n{:#?}", result.documents_ids, result.document_scores.iter().map(|scores| format!("{:.4} ", ScoreDetails::global_score(scores.iter()))).collect::<String>(), result.document_scores), @r###"
|
||||||
[
|
IDs: [4, 1, 0, 3]
|
||||||
4,
|
Scores: 1.0000 0.9167 0.8333 0.3333
|
||||||
1,
|
Score Details:
|
||||||
0,
|
|
||||||
3,
|
|
||||||
]
|
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
Words(
|
Words(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user