mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
Plug the deletion pipeline
This commit is contained in:
parent
470c2272dd
commit
39b27e42be
@ -1500,26 +1500,35 @@ impl IndexScheduler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = IndexDocumentsConfig {
|
let rtxn = index.read_txn()?;
|
||||||
update_method: IndexDocumentsMethod::ReplaceDocuments,
|
let mut fields_ids_map = index.fields_ids_map(&rtxn)?;
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let must_stop_processing = self.must_stop_processing.clone();
|
let primary_key =
|
||||||
let mut builder = milli::update::IndexDocuments::new(
|
retrieve_or_guess_primary_key(&rtxn, index, &mut fields_ids_map, None)?
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
if !tasks.iter().all(|res| res.error.is_some()) {
|
||||||
|
/// TODO create a pool if needed
|
||||||
|
// let pool = indexer_config.thread_pool.unwrap();
|
||||||
|
let pool = rayon::ThreadPoolBuilder::new().build().unwrap();
|
||||||
|
|
||||||
|
let param = (index, &fields_ids_map, &primary_key);
|
||||||
|
let mut indexer = indexer::DocumentDeletion::new();
|
||||||
|
indexer.delete_documents_by_docids(to_delete);
|
||||||
|
/// TODO remove this fields-ids-map, it's useless for the deletion pipeline (the &mut cloned one).
|
||||||
|
let document_changes =
|
||||||
|
indexer.document_changes(&mut fields_ids_map.clone(), param)?;
|
||||||
|
/// TODO pass/write the FieldsIdsMap
|
||||||
|
indexer::index(
|
||||||
index_wtxn,
|
index_wtxn,
|
||||||
index,
|
index,
|
||||||
self.index_mapper.indexer_config(),
|
fields_ids_map.clone(),
|
||||||
config,
|
&pool,
|
||||||
|indexing_step| tracing::debug!(update = ?indexing_step),
|
document_changes,
|
||||||
|| must_stop_processing.get(),
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let (new_builder, _count) =
|
// tracing::info!(indexing_result = ?addition, processed_in = ?started_processing_at.elapsed(), "document indexing done");
|
||||||
builder.remove_documents_from_db_no_batch(&to_delete)?;
|
}
|
||||||
builder = new_builder;
|
|
||||||
|
|
||||||
let _ = builder.execute()?;
|
|
||||||
|
|
||||||
Ok(tasks)
|
Ok(tasks)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ impl<'p> DocumentChanges<'p> for DocumentDeletion {
|
|||||||
|rtxn, docid| {
|
|rtxn, docid| {
|
||||||
let current = index.document(rtxn, docid)?;
|
let current = index.document(rtxn, docid)?;
|
||||||
let external_document_id = primary_key
|
let external_document_id = primary_key
|
||||||
.document_id(¤t, fields_ids_map)?
|
.document_id(current, fields_ids_map)?
|
||||||
.map_err(|_| InternalError::DatabaseMissingEntry {
|
.map_err(|_| InternalError::DatabaseMissingEntry {
|
||||||
db_name: EXTERNAL_DOCUMENTS_IDS,
|
db_name: EXTERNAL_DOCUMENTS_IDS,
|
||||||
key: None,
|
key: None,
|
||||||
|
Loading…
Reference in New Issue
Block a user