mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
implements the index deletion, creation and swap
This commit is contained in:
parent
fa27485070
commit
b1f0431ab4
4 changed files with 70 additions and 7 deletions
|
@ -22,6 +22,7 @@ use super::{Checked, Settings};
|
|||
|
||||
pub type Document = Map<String, Value>;
|
||||
|
||||
// @kero, what is this structure? Shouldn't it move entirely to milli?
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct IndexMeta {
|
||||
|
@ -50,6 +51,7 @@ impl IndexMeta {
|
|||
}
|
||||
}
|
||||
|
||||
// @kero Maybe this should be entirely generated somewhere else since it doesn't really concern the index?
|
||||
#[derive(Serialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct IndexStats {
|
||||
|
@ -105,6 +107,14 @@ impl Index {
|
|||
self.inner.as_ref().clone().prepare_for_closing();
|
||||
}
|
||||
|
||||
pub fn delete(self) -> Result<()> {
|
||||
let path = self.path().to_path_buf();
|
||||
self.inner.as_ref().clone().prepare_for_closing().wait();
|
||||
std::fs::remove_file(path)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn stats(&self) -> Result<IndexStats> {
|
||||
let rtxn = self.read_txn()?;
|
||||
|
||||
|
|
|
@ -137,6 +137,13 @@ pub mod test {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn delete(self) -> Result<()> {
|
||||
match self {
|
||||
MockIndex::Real(index) => index.delete(),
|
||||
MockIndex::Mock(m) => unsafe { m.get("delete").call(()) },
|
||||
}
|
||||
}
|
||||
|
||||
pub fn perform_search(&self, query: SearchQuery) -> Result<SearchResult> {
|
||||
match self {
|
||||
MockIndex::Real(index) => index.perform_search(query),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue