mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-25 19:45:05 +08:00
Make sure we edit the task statuses
This commit is contained in:
parent
7e1dc8439b
commit
52b95c4e59
@ -1424,6 +1424,8 @@ impl IndexScheduler {
|
|||||||
retrieve_or_guess_primary_key(&rtxn, index, &mut new_fields_ids_map, None)?
|
retrieve_or_guess_primary_key(&rtxn, index, &mut new_fields_ids_map, None)?
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let result_count = Ok((candidates.len(), candidates.len())) as Result<_>;
|
||||||
|
|
||||||
if task.error.is_none() {
|
if task.error.is_none() {
|
||||||
/// TODO create a pool if needed
|
/// TODO create a pool if needed
|
||||||
// let pool = indexer_config.thread_pool.unwrap();
|
// let pool = indexer_config.thread_pool.unwrap();
|
||||||
@ -1444,42 +1446,42 @@ impl IndexScheduler {
|
|||||||
// tracing::info!(indexing_result = ?addition, processed_in = ?started_processing_at.elapsed(), "document indexing done");
|
// tracing::info!(indexing_result = ?addition, processed_in = ?started_processing_at.elapsed(), "document indexing done");
|
||||||
}
|
}
|
||||||
|
|
||||||
// let (original_filter, context, function) = if let Some(Details::DocumentEdition {
|
let (original_filter, context, function) = if let Some(Details::DocumentEdition {
|
||||||
// original_filter,
|
original_filter,
|
||||||
// context,
|
context,
|
||||||
// function,
|
function,
|
||||||
// ..
|
..
|
||||||
// }) = task.details
|
}) = task.details
|
||||||
// {
|
{
|
||||||
// (original_filter, context, function)
|
(original_filter, context, function)
|
||||||
// } else {
|
} else {
|
||||||
// // In the case of a `documentEdition` the details MUST be set
|
// In the case of a `documentEdition` the details MUST be set
|
||||||
// unreachable!();
|
unreachable!();
|
||||||
// };
|
};
|
||||||
|
|
||||||
// match result_count {
|
match result_count {
|
||||||
// Ok((deleted_documents, edited_documents)) => {
|
Ok((deleted_documents, edited_documents)) => {
|
||||||
// task.status = Status::Succeeded;
|
task.status = Status::Succeeded;
|
||||||
// task.details = Some(Details::DocumentEdition {
|
task.details = Some(Details::DocumentEdition {
|
||||||
// original_filter,
|
original_filter,
|
||||||
// context,
|
context,
|
||||||
// function,
|
function,
|
||||||
// deleted_documents: Some(deleted_documents),
|
deleted_documents: Some(deleted_documents),
|
||||||
// edited_documents: Some(edited_documents),
|
edited_documents: Some(edited_documents),
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
// Err(e) => {
|
Err(e) => {
|
||||||
// task.status = Status::Failed;
|
task.status = Status::Failed;
|
||||||
// task.details = Some(Details::DocumentEdition {
|
task.details = Some(Details::DocumentEdition {
|
||||||
// original_filter,
|
original_filter,
|
||||||
// context,
|
context,
|
||||||
// function,
|
function,
|
||||||
// deleted_documents: Some(0),
|
deleted_documents: Some(0),
|
||||||
// edited_documents: Some(0),
|
edited_documents: Some(0),
|
||||||
// });
|
});
|
||||||
// task.error = Some(e.into());
|
task.error = Some(e.into());
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
Ok(vec![task])
|
Ok(vec![task])
|
||||||
}
|
}
|
||||||
|
@ -113,16 +113,15 @@ impl<'index> DocumentChanges<'index> for UpdateByFunctionChanges<'index> {
|
|||||||
scope.push_constant_dynamic("context", context.clone());
|
scope.push_constant_dynamic("context", context.clone());
|
||||||
}
|
}
|
||||||
scope.push("doc", rhai_document);
|
scope.push("doc", rhai_document);
|
||||||
// That's were the magic happens. We run the user script
|
// We run the user script which edits "doc" scope variable reprensenting
|
||||||
// which edits "doc" scope variable reprensenting the document
|
// the document and ignore the output and even the type of it, i.e., Dynamic.
|
||||||
// and ignore the output and even the type of it, i.e., Dynamic.
|
|
||||||
let _ = self
|
let _ = self
|
||||||
.engine
|
.engine
|
||||||
.eval_ast_with_scope::<Dynamic>(&mut scope, &self.ast)
|
.eval_ast_with_scope::<Dynamic>(&mut scope, &self.ast)
|
||||||
.map_err(UserError::DocumentEditionRuntimeError)?;
|
.map_err(UserError::DocumentEditionRuntimeError)?;
|
||||||
|
|
||||||
match scope.remove::<Dynamic>("doc") {
|
match scope.remove::<Dynamic>("doc") {
|
||||||
// If the "doc" variable has set to (), we effectively delete the document.
|
// If the "doc" variable has been set to (), we effectively delete the document.
|
||||||
Some(doc) if doc.is_unit() => Ok(Some(DocumentChange::Deletion(Deletion::create(
|
Some(doc) if doc.is_unit() => Ok(Some(DocumentChange::Deletion(Deletion::create(
|
||||||
docid,
|
docid,
|
||||||
doc_alloc.alloc_str(&document_id),
|
doc_alloc.alloc_str(&document_id),
|
||||||
@ -142,7 +141,7 @@ impl<'index> DocumentChanges<'index> for UpdateByFunctionChanges<'index> {
|
|||||||
//
|
//
|
||||||
// Future: Use a custom function rhai function to track changes.
|
// Future: Use a custom function rhai function to track changes.
|
||||||
// <https://docs.rs/rhai/latest/rhai/struct.Engine.html#method.register_indexer_set>
|
// <https://docs.rs/rhai/latest/rhai/struct.Engine.html#method.register_indexer_set>
|
||||||
if json_document != rhaimap_to_object(new_rhai_document) {
|
if dbg!(json_document) != dbg!(rhaimap_to_object(new_rhai_document)) {
|
||||||
let mut global_fields_ids_map = new_fields_ids_map.borrow_mut();
|
let mut global_fields_ids_map = new_fields_ids_map.borrow_mut();
|
||||||
let new_document_id = self
|
let new_document_id = self
|
||||||
.primary_key
|
.primary_key
|
||||||
|
Loading…
Reference in New Issue
Block a user