mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 06:44:27 +01:00
Implement the Settings batch operation
This commit is contained in:
parent
7b4a913704
commit
41ec737e73
@ -35,6 +35,7 @@ pub(crate) enum Batch {
|
|||||||
},
|
},
|
||||||
Settings {
|
Settings {
|
||||||
index_uid: String,
|
index_uid: String,
|
||||||
|
// TODO what's that boolean, does it mean that it removes things or what?
|
||||||
settings: Vec<(bool, Settings<Unchecked>)>,
|
settings: Vec<(bool, Settings<Unchecked>)>,
|
||||||
tasks: Vec<Task>,
|
tasks: Vec<Task>,
|
||||||
},
|
},
|
||||||
@ -460,9 +461,7 @@ impl IndexScheduler {
|
|||||||
indexed_documents,
|
indexed_documents,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => task.error = Some(error.into()),
|
||||||
task.error = Some(error.into());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,9 +508,7 @@ impl IndexScheduler {
|
|||||||
indexed_documents,
|
indexed_documents,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => task.error = Some(error.into()),
|
||||||
task.error = Some(error.into());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,9 +536,7 @@ impl IndexScheduler {
|
|||||||
deleted_documents: Some(deleted_documents),
|
deleted_documents: Some(deleted_documents),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Err(ref error) => {
|
Err(ref error) => task.error = Some(error.into()),
|
||||||
task.error = Some(error.into());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,8 +545,25 @@ impl IndexScheduler {
|
|||||||
Batch::Settings {
|
Batch::Settings {
|
||||||
index_uid,
|
index_uid,
|
||||||
settings,
|
settings,
|
||||||
tasks,
|
mut tasks,
|
||||||
} => todo!(),
|
} => {
|
||||||
|
// we NEED a write transaction for the index creation.
|
||||||
|
// To avoid blocking the whole process we're going to commit asap.
|
||||||
|
let mut wtxn = self.env.write_txn()?;
|
||||||
|
let index = self.index_mapper.create_index(&mut wtxn, &index_uid)?;
|
||||||
|
wtxn.commit()?;
|
||||||
|
|
||||||
|
// TODO merge the settings to only do a reindexation once.
|
||||||
|
for (task, (_, settings)) in tasks.iter_mut().zip(settings) {
|
||||||
|
let checked_settings = settings.clone().check();
|
||||||
|
task.details = Some(Details::Settings { settings });
|
||||||
|
if let Err(error) = index.update_settings(&checked_settings) {
|
||||||
|
task.error = Some(error.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(tasks)
|
||||||
|
}
|
||||||
Batch::DocumentClearAndSetting {
|
Batch::DocumentClearAndSetting {
|
||||||
index_uid,
|
index_uid,
|
||||||
cleared_tasks,
|
cleared_tasks,
|
||||||
|
Loading…
Reference in New Issue
Block a user