mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-08-01 11:20:04 +00:00
feat: Make the Attribute and WordArea errors recoverable
This commit is contained in:
@ -54,8 +54,20 @@ mod tests {
|
||||
fn one_typo_reference() {
|
||||
let doc0 = {
|
||||
let matches = vec![
|
||||
Match { query_index: 0, distance: 0, attribute: Attribute::new(0, 0), is_exact: false, word_area: WordArea::new(0, 6) },
|
||||
Match { query_index: 1, distance: 0, attribute: Attribute::new(0, 2), is_exact: false, word_area: WordArea::new(0, 6) },
|
||||
Match {
|
||||
query_index: 0,
|
||||
distance: 0,
|
||||
attribute: Attribute::new_faillible(0, 0),
|
||||
is_exact: false,
|
||||
word_area: WordArea::new_faillible(0, 6)
|
||||
},
|
||||
Match {
|
||||
query_index: 1,
|
||||
distance: 0,
|
||||
attribute: Attribute::new_faillible(0, 2),
|
||||
is_exact: false,
|
||||
word_area: WordArea::new_faillible(0, 6)
|
||||
},
|
||||
];
|
||||
Document {
|
||||
id: DocumentId(0),
|
||||
@ -65,8 +77,20 @@ mod tests {
|
||||
|
||||
let doc1 = {
|
||||
let matches = vec![
|
||||
Match { query_index: 0, distance: 1, attribute: Attribute::new(0, 0), is_exact: false, word_area: WordArea::new(0, 6) },
|
||||
Match { query_index: 1, distance: 0, attribute: Attribute::new(0, 2), is_exact: false, word_area: WordArea::new(0, 6) },
|
||||
Match {
|
||||
query_index: 0,
|
||||
distance: 1,
|
||||
attribute: Attribute::new_faillible(0, 0),
|
||||
is_exact: false,
|
||||
word_area: WordArea::new_faillible(0, 6)
|
||||
},
|
||||
Match {
|
||||
query_index: 1,
|
||||
distance: 0,
|
||||
attribute: Attribute::new_faillible(0, 2),
|
||||
is_exact: false,
|
||||
word_area: WordArea::new_faillible(0, 6)
|
||||
},
|
||||
];
|
||||
Document {
|
||||
id: DocumentId(1),
|
||||
@ -87,8 +111,20 @@ mod tests {
|
||||
fn no_typo() {
|
||||
let doc0 = {
|
||||
let matches = vec![
|
||||
Match { query_index: 0, distance: 0, attribute: Attribute::new(0, 0), is_exact: false, word_area: WordArea::new(0, 6) },
|
||||
Match { query_index: 1, distance: 0, attribute: Attribute::new(0, 1), is_exact: false, word_area: WordArea::new(0, 6) },
|
||||
Match {
|
||||
query_index: 0,
|
||||
distance: 0,
|
||||
attribute: Attribute::new_faillible(0, 0),
|
||||
is_exact: false,
|
||||
word_area: WordArea::new_faillible(0, 6)
|
||||
},
|
||||
Match {
|
||||
query_index: 1,
|
||||
distance: 0,
|
||||
attribute: Attribute::new_faillible(0, 1),
|
||||
is_exact: false,
|
||||
word_area: WordArea::new_faillible(0, 6)
|
||||
},
|
||||
];
|
||||
Document {
|
||||
id: DocumentId(0),
|
||||
@ -98,7 +134,13 @@ mod tests {
|
||||
|
||||
let doc1 = {
|
||||
let matches = vec![
|
||||
Match { query_index: 0, distance: 0, attribute: Attribute::new(0, 0), is_exact: false, word_area: WordArea::new(0, 6) },
|
||||
Match {
|
||||
query_index: 0,
|
||||
distance: 0,
|
||||
attribute: Attribute::new_faillible(0, 0),
|
||||
is_exact: false,
|
||||
word_area: WordArea::new_faillible(0, 6)
|
||||
},
|
||||
];
|
||||
Document {
|
||||
id: DocumentId(1),
|
||||
@ -119,8 +161,20 @@ mod tests {
|
||||
fn one_typo() {
|
||||
let doc0 = {
|
||||
let matches = vec![
|
||||
Match { query_index: 0, distance: 0, attribute: Attribute::new(0, 0), is_exact: false, word_area: WordArea::new(0, 6) },
|
||||
Match { query_index: 1, distance: 1, attribute: Attribute::new(0, 1), is_exact: false, word_area: WordArea::new(0, 6) },
|
||||
Match {
|
||||
query_index: 0,
|
||||
distance: 0,
|
||||
attribute: Attribute::new_faillible(0, 0),
|
||||
is_exact: false,
|
||||
word_area: WordArea::new_faillible(0, 6)
|
||||
},
|
||||
Match {
|
||||
query_index: 1,
|
||||
distance: 1,
|
||||
attribute: Attribute::new_faillible(0, 1),
|
||||
is_exact: false,
|
||||
word_area: WordArea::new_faillible(0, 6)
|
||||
},
|
||||
];
|
||||
Document {
|
||||
id: DocumentId(0),
|
||||
@ -130,7 +184,13 @@ mod tests {
|
||||
|
||||
let doc1 = {
|
||||
let matches = vec![
|
||||
Match { query_index: 0, distance: 0, attribute: Attribute::new(0, 0), is_exact: false, word_area: WordArea::new(0, 6) },
|
||||
Match {
|
||||
query_index: 0,
|
||||
distance: 0,
|
||||
attribute: Attribute::new_faillible(0, 0),
|
||||
is_exact: false,
|
||||
word_area: WordArea::new_faillible(0, 6)
|
||||
},
|
||||
];
|
||||
Document {
|
||||
id: DocumentId(1),
|
||||
|
@ -81,11 +81,11 @@ mod tests {
|
||||
// { id: 3, attr: 3, attr_index: 1 }
|
||||
|
||||
let matches = &[
|
||||
Match { query_index: 0, attribute: Attribute::new(0, 0), ..Match::zero() },
|
||||
Match { query_index: 1, attribute: Attribute::new(1, 0), ..Match::zero() },
|
||||
Match { query_index: 2, attribute: Attribute::new(1, 1), ..Match::zero() },
|
||||
Match { query_index: 2, attribute: Attribute::new(2, 0), ..Match::zero() },
|
||||
Match { query_index: 3, attribute: Attribute::new(3, 1), ..Match::zero() },
|
||||
Match { query_index: 0, attribute: Attribute::new_faillible(0, 0), ..Match::zero() },
|
||||
Match { query_index: 1, attribute: Attribute::new_faillible(1, 0), ..Match::zero() },
|
||||
Match { query_index: 2, attribute: Attribute::new_faillible(1, 1), ..Match::zero() },
|
||||
Match { query_index: 2, attribute: Attribute::new_faillible(2, 0), ..Match::zero() },
|
||||
Match { query_index: 3, attribute: Attribute::new_faillible(3, 1), ..Match::zero() },
|
||||
];
|
||||
|
||||
// soup -> of = 8
|
||||
@ -107,12 +107,12 @@ mod tests {
|
||||
// { id: 3, attr: 1, attr_index: 3 }
|
||||
|
||||
let matches = &[
|
||||
Match { query_index: 0, attribute: Attribute::new(0, 0), ..Match::zero() },
|
||||
Match { query_index: 0, attribute: Attribute::new(1, 0), ..Match::zero() },
|
||||
Match { query_index: 1, attribute: Attribute::new(1, 1), ..Match::zero() },
|
||||
Match { query_index: 2, attribute: Attribute::new(1, 2), ..Match::zero() },
|
||||
Match { query_index: 3, attribute: Attribute::new(0, 1), ..Match::zero() },
|
||||
Match { query_index: 3, attribute: Attribute::new(1, 3), ..Match::zero() },
|
||||
Match { query_index: 0, attribute: Attribute::new_faillible(0, 0), ..Match::zero() },
|
||||
Match { query_index: 0, attribute: Attribute::new_faillible(1, 0), ..Match::zero() },
|
||||
Match { query_index: 1, attribute: Attribute::new_faillible(1, 1), ..Match::zero() },
|
||||
Match { query_index: 2, attribute: Attribute::new_faillible(1, 2), ..Match::zero() },
|
||||
Match { query_index: 3, attribute: Attribute::new_faillible(0, 1), ..Match::zero() },
|
||||
Match { query_index: 3, attribute: Attribute::new_faillible(1, 3), ..Match::zero() },
|
||||
];
|
||||
|
||||
// soup -> of = 1
|
||||
|
Reference in New Issue
Block a user