Introduce an indexation abortion function when indexing documents

This commit is contained in:
Kerollmops
2022-10-05 17:41:07 +02:00
parent fad0de4581
commit 6603437cb1
14 changed files with 379 additions and 136 deletions

View File

@ -40,7 +40,7 @@ fn test_typo_tolerance_one_typo() {
let config = IndexerConfig::default();
let mut builder = Settings::new(&mut txn, &index, &config);
builder.set_min_word_len_one_typo(4);
builder.execute(|_| ()).unwrap();
builder.execute(|_| (), || false).unwrap();
// typo is now supported for 4 letters words
let mut search = Search::new(&txn, &index);
@ -86,7 +86,7 @@ fn test_typo_tolerance_two_typo() {
let config = IndexerConfig::default();
let mut builder = Settings::new(&mut txn, &index, &config);
builder.set_min_word_len_two_typos(7);
builder.execute(|_| ()).unwrap();
builder.execute(|_| (), || false).unwrap();
// typo is now supported for 4 letters words
let mut search = Search::new(&txn, &index);
@ -127,7 +127,8 @@ fn test_typo_disabled_on_word() {
let mut txn = index.write_txn().unwrap();
let config = IndexerConfig::default();
let indexing_config = IndexDocumentsConfig::default();
let builder = IndexDocuments::new(&mut txn, &index, &config, indexing_config, |_| ()).unwrap();
let builder =
IndexDocuments::new(&mut txn, &index, &config, indexing_config, |_| (), || false).unwrap();
let (builder, user_error) = builder.add_documents(documents).unwrap();
user_error.unwrap();
@ -156,7 +157,7 @@ fn test_typo_disabled_on_word() {
// `zealand` doesn't allow typos anymore
exact_words.insert("zealand".to_string());
builder.set_exact_words(exact_words);
builder.execute(|_| ()).unwrap();
builder.execute(|_| (), || false).unwrap();
let mut search = Search::new(&txn, &index);
search.query("zealand");
@ -194,7 +195,7 @@ fn test_disable_typo_on_attribute() {
let mut builder = Settings::new(&mut txn, &index, &config);
// disable typos on `description`
builder.set_exact_attributes(vec!["description".to_string()].into_iter().collect());
builder.execute(|_| ()).unwrap();
builder.execute(|_| (), || false).unwrap();
let mut search = Search::new(&txn, &index);
search.query("antebelum");