mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-08-01 19:30:01 +00:00
Add more tests and allow disabling of soft-deletion outside of tests
Also allow disabling soft-deletion in the IndexDocumentsConfig
This commit is contained in:
@ -88,6 +88,7 @@ pub struct IndexDocumentsConfig {
|
||||
pub words_positions_level_group_size: Option<NonZeroU32>,
|
||||
pub words_positions_min_level_size: Option<NonZeroU32>,
|
||||
pub update_method: IndexDocumentsMethod,
|
||||
pub disable_soft_deletion: bool,
|
||||
pub autogenerate_docids: bool,
|
||||
}
|
||||
|
||||
@ -331,6 +332,7 @@ where
|
||||
// able to simply insert all the documents even if they already exist in the database.
|
||||
if !replaced_documents_ids.is_empty() {
|
||||
let mut deletion_builder = update::DeleteDocuments::new(self.wtxn, self.index)?;
|
||||
deletion_builder.disable_soft_deletion(self.config.disable_soft_deletion);
|
||||
debug!("documents to delete {:?}", replaced_documents_ids);
|
||||
deletion_builder.delete_documents(&replaced_documents_ids);
|
||||
let deleted_documents_count = deletion_builder.execute()?;
|
||||
@ -906,6 +908,8 @@ mod tests {
|
||||
{ "id": 42, "title": "The Hitchhiker's Guide to the Galaxy", "author": "Douglas Adams", "_geo": { "lat": 35, "lng": 23 } }
|
||||
])).unwrap();
|
||||
|
||||
db_snap!(index, word_docids, "initial");
|
||||
|
||||
index.index_documents_config.update_method = IndexDocumentsMethod::UpdateDocuments;
|
||||
|
||||
index
|
||||
@ -928,6 +932,9 @@ mod tests {
|
||||
let count = index.all_documents(&rtxn).unwrap().count();
|
||||
assert_eq!(count, 6);
|
||||
|
||||
db_snap!(index, word_docids, "updated");
|
||||
db_snap!(index, soft_deleted_documents_ids, "updated", @"[0, 1, 4, ]");
|
||||
|
||||
drop(rtxn);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,54 @@
|
||||
---
|
||||
source: milli/src/update/index_documents/mod.rs
|
||||
---
|
||||
1 [2, ]
|
||||
10.0 [1, ]
|
||||
12 [0, ]
|
||||
1344 [3, ]
|
||||
2 [0, ]
|
||||
23 [5, ]
|
||||
25.99 [2, ]
|
||||
3.5 [0, ]
|
||||
35 [5, ]
|
||||
4 [4, ]
|
||||
42 [0, 5, ]
|
||||
456 [1, ]
|
||||
adams [5, ]
|
||||
adventure [1, ]
|
||||
alice [2, ]
|
||||
and [0, 4, ]
|
||||
antoine [1, ]
|
||||
austin [0, ]
|
||||
blood [4, ]
|
||||
carroll [2, ]
|
||||
de [1, ]
|
||||
douglas [5, ]
|
||||
exupery [1, ]
|
||||
fantasy [2, 3, 4, ]
|
||||
galaxy [5, ]
|
||||
guide [5, ]
|
||||
half [4, ]
|
||||
harry [4, ]
|
||||
hitchhiker' [5, ]
|
||||
hobbit [3, ]
|
||||
in [2, ]
|
||||
j [3, 4, ]
|
||||
jane [0, ]
|
||||
k [4, ]
|
||||
le [1, ]
|
||||
lewis [2, ]
|
||||
petit [1, ]
|
||||
potter [4, ]
|
||||
prejudice [0, ]
|
||||
pride [0, ]
|
||||
prince [1, 4, ]
|
||||
r [3, ]
|
||||
romance [0, ]
|
||||
rowling [4, ]
|
||||
s [5, ]
|
||||
saint [1, ]
|
||||
the [3, 4, 5, ]
|
||||
to [5, ]
|
||||
tolkien [3, ]
|
||||
wonderland [2, ]
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
source: milli/src/update/index_documents/mod.rs
|
||||
---
|
||||
[0, 1, 4, ]
|
@ -0,0 +1,58 @@
|
||||
---
|
||||
source: milli/src/update/index_documents/mod.rs
|
||||
---
|
||||
1 [2, ]
|
||||
10.0 [1, 7, ]
|
||||
12 [0, 8, ]
|
||||
1344 [3, ]
|
||||
1813 [8, ]
|
||||
2 [0, 8, ]
|
||||
23 [5, ]
|
||||
25.99 [2, ]
|
||||
3.5 [0, 8, ]
|
||||
35 [5, ]
|
||||
4 [4, 6, ]
|
||||
42 [0, 5, 8, ]
|
||||
456 [1, 7, ]
|
||||
adams [5, ]
|
||||
adventure [1, 7, ]
|
||||
alice [2, ]
|
||||
and [0, 4, 6, 8, ]
|
||||
antoine [1, 7, ]
|
||||
austen [8, ]
|
||||
austin [0, ]
|
||||
blood [4, 6, ]
|
||||
carroll [2, ]
|
||||
de [1, 7, ]
|
||||
douglas [5, ]
|
||||
exupery [1, 7, ]
|
||||
fantasy [2, 3, 4, 6, ]
|
||||
galaxy [5, ]
|
||||
guide [5, ]
|
||||
half [4, 6, ]
|
||||
harry [4, 6, ]
|
||||
hitchhiker' [5, ]
|
||||
hobbit [3, ]
|
||||
in [2, ]
|
||||
j [3, 4, 6, 8, ]
|
||||
jane [0, ]
|
||||
k [4, 6, ]
|
||||
le [1, ]
|
||||
lewis [2, ]
|
||||
little [7, ]
|
||||
petit [1, ]
|
||||
potter [4, 6, ]
|
||||
prejudice [0, 8, ]
|
||||
pride [0, 8, ]
|
||||
prince [1, 4, 7, ]
|
||||
princess [6, ]
|
||||
r [3, ]
|
||||
romance [0, 8, ]
|
||||
rowling [4, 6, ]
|
||||
s [5, ]
|
||||
saint [1, 7, ]
|
||||
the [3, 4, 5, 6, 7, ]
|
||||
to [5, ]
|
||||
tolkien [3, ]
|
||||
wonderland [2, ]
|
||||
|
Reference in New Issue
Block a user