From fc14f4bc66c77b2417ca9931963923ff285a9f42 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Tue, 19 Nov 2024 16:10:17 +0100 Subject: [PATCH] Attempt to fix setup_search_index_with_criteria --- crates/milli/src/search/new/tests/integration.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/milli/src/search/new/tests/integration.rs b/crates/milli/src/search/new/tests/integration.rs index 7880d4a8a..3f522e8ed 100644 --- a/crates/milli/src/search/new/tests/integration.rs +++ b/crates/milli/src/search/new/tests/integration.rs @@ -18,7 +18,6 @@ pub fn setup_search_index_with_criteria(criteria: &[Criterion]) -> Index { let index = Index::new(options, &path).unwrap(); let mut wtxn = index.write_txn().unwrap(); - let rtxn = index.read_txn().unwrap(); let config = IndexerConfig::default(); let mut builder = Settings::new(&mut wtxn, &index, &config); @@ -43,9 +42,12 @@ pub fn setup_search_index_with_criteria(criteria: &[Criterion]) -> Index { }); builder.set_searchable_fields(vec![S("title"), S("description")]); builder.execute(|_| (), || false).unwrap(); + wtxn.commit().unwrap(); // index documents let config = IndexerConfig { max_memory: Some(10 * 1024 * 1024), ..Default::default() }; + let mut wtxn = index.write_txn().unwrap(); + let rtxn = index.read_txn().unwrap(); let db_fields_ids_map = index.fields_ids_map(&rtxn).unwrap(); let mut new_fields_ids_map = db_fields_ids_map.clone(); @@ -62,9 +64,13 @@ pub fn setup_search_index_with_criteria(criteria: &[Criterion]) -> Index { indexer.add_documents(&payload).unwrap(); let indexer_alloc = Bump::new(); - let (document_changes, _operation_stats, primary_key) = + let (document_changes, operation_stats, primary_key) = indexer.into_changes(&indexer_alloc, &index, &rtxn, None, &mut new_fields_ids_map).unwrap(); + if let Some(error) = operation_stats.into_iter().find_map(|stat| stat.error) { + panic!("{error}"); + } + indexer::index( &mut wtxn, &index,