mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 11:57:07 +02:00
Add support to upgrade to v1.12.3 in meilitool
This commit is contained in:
parent
a21711f473
commit
4070895a21
6 changed files with 183 additions and 4 deletions
|
@ -16,6 +16,7 @@ pub mod indexer;
|
|||
mod merger;
|
||||
mod parallel_iterator_ext;
|
||||
mod ref_cell_ext;
|
||||
pub mod reindex;
|
||||
pub(crate) mod steps;
|
||||
pub(crate) mod thread_local;
|
||||
pub mod vector_document;
|
||||
|
|
47
crates/milli/src/update/new/reindex.rs
Normal file
47
crates/milli/src/update/new/reindex.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
use heed::RwTxn;
|
||||
|
||||
use super::document::{Document, DocumentFromDb};
|
||||
use crate::progress::{self, AtomicSubStep, NamedStep, Progress};
|
||||
use crate::{FieldDistribution, Index, Result};
|
||||
|
||||
pub fn field_distribution(index: &Index, wtxn: &mut RwTxn<'_>, progress: &Progress) -> Result<()> {
|
||||
let mut distribution = FieldDistribution::new();
|
||||
|
||||
let document_count = index.number_of_documents(wtxn)?;
|
||||
let field_id_map = index.fields_ids_map(wtxn)?;
|
||||
|
||||
let (update_document_count, sub_step) =
|
||||
AtomicSubStep::<progress::Document>::new(document_count as u32);
|
||||
progress.update_progress(sub_step);
|
||||
|
||||
let docids = index.documents_ids(wtxn)?;
|
||||
|
||||
for docid in docids {
|
||||
update_document_count.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
|
||||
let Some(document) = DocumentFromDb::new(docid, wtxn, index, &field_id_map)? else {
|
||||
continue;
|
||||
};
|
||||
let geo_iter = document.geo_field().transpose().map(|res| res.map(|rv| ("_geo", rv)));
|
||||
for res in document.iter_top_level_fields().chain(geo_iter) {
|
||||
let (field_name, _) = res?;
|
||||
if let Some(count) = distribution.get_mut(field_name) {
|
||||
*count += 1;
|
||||
} else {
|
||||
distribution.insert(field_name.to_owned(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
index.put_field_distribution(wtxn, &distribution)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FieldDistributionIndexProgress;
|
||||
|
||||
impl NamedStep for FieldDistributionIndexProgress {
|
||||
fn name(&self) -> &'static str {
|
||||
"documents"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue