mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
implement list all indexes
This commit is contained in:
parent
60371b9dcf
commit
6c63ee6798
6 changed files with 52 additions and 31 deletions
|
@ -9,6 +9,7 @@ use std::sync::Arc;
|
|||
|
||||
use milli::Index;
|
||||
use anyhow::bail;
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::option::IndexerOpts;
|
||||
use super::IndexController;
|
||||
|
@ -81,4 +82,25 @@ impl IndexController for LocalIndexController {
|
|||
None => bail!("index {:?} doesn't exist", index.as_ref()),
|
||||
}
|
||||
}
|
||||
|
||||
fn all_update_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus<UpdateMeta, UpdateResult, String>>> {
|
||||
match self.indexes.index(index)? {
|
||||
Some((_, update_store)) => {
|
||||
let updates = update_store.iter_metas(|processing, processed, pending, aborted, failed| {
|
||||
Ok(processing
|
||||
.map(UpdateStatus::from)
|
||||
.into_iter()
|
||||
.chain(pending.filter_map(|p| p.ok()).map(|(_, u)| UpdateStatus::from(u)))
|
||||
.chain(aborted.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
||||
.chain(processed.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
||||
.chain(failed.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
||||
.sorted_by(|a, b| a.id().cmp(&b.id()))
|
||||
.collect())
|
||||
})?;
|
||||
Ok(updates)
|
||||
}
|
||||
None => Ok(Vec::new())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,4 +137,5 @@ pub trait IndexController {
|
|||
fn index(&self, uid: impl AsRef<str>) -> anyhow::Result<Option<Arc<Index>>>;
|
||||
|
||||
fn update_status(&self, index: impl AsRef<str>, id: u64) -> anyhow::Result<Option<UpdateStatus<UpdateMeta, UpdateResult, String>>>;
|
||||
fn all_update_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus<UpdateMeta, UpdateResult, String>>>;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue