mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-03 10:21:38 +01:00
implement list all indexes
This commit is contained in:
parent
60371b9dcf
commit
6c63ee6798
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -1452,6 +1452,15 @@ dependencies = [
|
|||||||
"either",
|
"either",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37d572918e350e82412fe766d24b15e6682fb2ed2bbe018280caa810397cb319"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "0.4.6"
|
version = "0.4.6"
|
||||||
@ -1650,6 +1659,7 @@ dependencies = [
|
|||||||
"heed",
|
"heed",
|
||||||
"http",
|
"http",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
"itertools 0.10.0",
|
||||||
"jemallocator",
|
"jemallocator",
|
||||||
"log",
|
"log",
|
||||||
"main_error",
|
"main_error",
|
||||||
@ -1745,7 +1755,7 @@ dependencies = [
|
|||||||
"grenad",
|
"grenad",
|
||||||
"heed",
|
"heed",
|
||||||
"human_format",
|
"human_format",
|
||||||
"itertools",
|
"itertools 0.9.0",
|
||||||
"jemallocator",
|
"jemallocator",
|
||||||
"levenshtein_automata",
|
"levenshtein_automata",
|
||||||
"linked-hash-map",
|
"linked-hash-map",
|
||||||
@ -3699,6 +3709,6 @@ checksum = "a1e6e8778706838f43f771d80d37787cb2fe06dafe89dd3aebaf6721b9eaec81"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"glob",
|
"glob",
|
||||||
"itertools",
|
"itertools 0.9.0",
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
@ -63,6 +63,7 @@ page_size = "0.4.2"
|
|||||||
obkv = "0.1.1"
|
obkv = "0.1.1"
|
||||||
ouroboros = "0.8.0"
|
ouroboros = "0.8.0"
|
||||||
uuid = "0.8.2"
|
uuid = "0.8.2"
|
||||||
|
itertools = "0.10.0"
|
||||||
|
|
||||||
[dependencies.sentry]
|
[dependencies.sentry]
|
||||||
default-features = false
|
default-features = false
|
||||||
|
@ -57,19 +57,7 @@ impl Data {
|
|||||||
self.index_controller.update_status(index, uid)
|
self.index_controller.update_status(index, uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
//pub fn get_updates_status(&self, _index: &str) -> anyhow::Result<Vec<UpdateStatus<UpdateMeta, UpdateResult, String>>> {
|
pub fn get_updates_status(&self, index: &str) -> anyhow::Result<Vec<UpdateStatus<UpdateMeta, UpdateResult, String>>> {
|
||||||
//let result = self.update_queue.iter_metas(|processing, processed, pending, aborted, failed| {
|
self.index_controller.all_update_status(index)
|
||||||
//let mut metas = processing
|
}
|
||||||
//.map(UpdateStatus::from)
|
|
||||||
//.into_iter()
|
|
||||||
//.chain(processed.filter_map(|i| Some(i.ok()?.1)).map(UpdateStatus::from))
|
|
||||||
//.chain(pending.filter_map(|i| Some(i.ok()?.1)).map(UpdateStatus::from))
|
|
||||||
//.chain(aborted.filter_map(|i| Some(i.ok()?.1)).map(UpdateStatus::from))
|
|
||||||
//.chain(failed.filter_map(|i| Some(i.ok()?.1)).map(UpdateStatus::from))
|
|
||||||
//.collect::<Vec<_>>();
|
|
||||||
//metas.sort_by(|a, b| a.id().cmp(&b.id()));
|
|
||||||
//Ok(metas)
|
|
||||||
//})?;
|
|
||||||
//Ok(result)
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use milli::Index;
|
use milli::Index;
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
use crate::option::IndexerOpts;
|
use crate::option::IndexerOpts;
|
||||||
use super::IndexController;
|
use super::IndexController;
|
||||||
@ -81,4 +82,25 @@ impl IndexController for LocalIndexController {
|
|||||||
None => bail!("index {:?} doesn't exist", index.as_ref()),
|
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 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 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>>>;
|
||||||
}
|
}
|
||||||
|
@ -124,19 +124,18 @@ async fn get_update_status(
|
|||||||
|
|
||||||
#[get("/indexes/{index_uid}/updates", wrap = "Authentication::Private")]
|
#[get("/indexes/{index_uid}/updates", wrap = "Authentication::Private")]
|
||||||
async fn get_all_updates_status(
|
async fn get_all_updates_status(
|
||||||
_data: web::Data<Data>,
|
data: web::Data<Data>,
|
||||||
_path: web::Path<IndexParam>,
|
path: web::Path<IndexParam>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
todo!()
|
let result = data.get_updates_status(&path.index_uid);
|
||||||
//let result = data.get_updates_status(&path.index_uid);
|
match result {
|
||||||
//match result {
|
Ok(metas) => {
|
||||||
//Ok(metas) => {
|
let json = serde_json::to_string(&metas).unwrap();
|
||||||
//let json = serde_json::to_string(&metas).unwrap();
|
Ok(HttpResponse::Ok().body(json))
|
||||||
//Ok(HttpResponse::Ok().body(json))
|
}
|
||||||
//}
|
Err(e) => {
|
||||||
//Err(e) => {
|
error!("{}", e);
|
||||||
//error!("{}", e);
|
todo!()
|
||||||
//todo!()
|
}
|
||||||
//}
|
}
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user