mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 20:45:06 +08:00
87a56d2bc9
replace ids with str in settings This allows for better maintainability of the settings code, since updating the searchable attributes is now straightforward. criterion use string fix reindexing fieldid remaping add tests for primary_key compute fix tests fix http-ui fixup! add tests for primary_key compute code improvements settings update deps fixup! code improvements settings fixup! refactor settings updates and fix bug fixup! Fix settings bug fixup! Fix settings bug fixup! Fix settings bug Update src/update/index_documents/transform.rs Co-authored-by: Clément Renault <clement@meilisearch.com> fixup! Fix settings bug
51 lines
1.8 KiB
Rust
51 lines
1.8 KiB
Rust
use roaring::RoaringBitmap;
|
|
use crate::{ExternalDocumentsIds, Index};
|
|
|
|
pub struct ClearDocuments<'t, 'u, 'i> {
|
|
wtxn: &'t mut heed::RwTxn<'i, 'u>,
|
|
index: &'i Index,
|
|
}
|
|
|
|
impl<'t, 'u, 'i> ClearDocuments<'t, 'u, 'i> {
|
|
pub fn new(wtxn: &'t mut heed::RwTxn<'i, 'u>, index: &'i Index) -> ClearDocuments<'t, 'u, 'i> {
|
|
ClearDocuments { wtxn, index }
|
|
}
|
|
|
|
pub fn execute(self) -> anyhow::Result<usize> {
|
|
let Index {
|
|
env: _env,
|
|
main: _main,
|
|
word_docids,
|
|
docid_word_positions,
|
|
word_pair_proximity_docids,
|
|
facet_field_id_value_docids,
|
|
field_id_docid_facet_values,
|
|
documents,
|
|
} = self.index;
|
|
|
|
// We retrieve the number of documents ids that we are deleting.
|
|
let number_of_documents = self.index.number_of_documents(self.wtxn)?;
|
|
let faceted_fields = self.index.faceted_fields_ids(self.wtxn)?;
|
|
|
|
// We clean some of the main engine datastructures.
|
|
self.index.put_words_fst(self.wtxn, &fst::Set::default())?;
|
|
self.index.put_external_documents_ids(self.wtxn, &ExternalDocumentsIds::default())?;
|
|
self.index.put_documents_ids(self.wtxn, &RoaringBitmap::default())?;
|
|
|
|
// We clean all the faceted documents ids.
|
|
for (field_id, _) in faceted_fields {
|
|
self.index.put_faceted_documents_ids(self.wtxn, field_id, &RoaringBitmap::default())?;
|
|
}
|
|
|
|
// Clear the other databases.
|
|
word_docids.clear(self.wtxn)?;
|
|
docid_word_positions.clear(self.wtxn)?;
|
|
word_pair_proximity_docids.clear(self.wtxn)?;
|
|
facet_field_id_value_docids.clear(self.wtxn)?;
|
|
field_id_docid_facet_values.clear(self.wtxn)?;
|
|
documents.clear(self.wtxn)?;
|
|
|
|
Ok(number_of_documents)
|
|
}
|
|
}
|