mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 13:24:27 +01:00
implement get index meta
This commit is contained in:
parent
8d462afb79
commit
f1c09a54be
@ -118,6 +118,13 @@ impl Data {
|
|||||||
self.index_controller.list_indexes()
|
self.index_controller.list_indexes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn index(&self, name: impl AsRef<str>) -> anyhow::Result<Option<IndexMetadata>> {
|
||||||
|
Ok(self
|
||||||
|
.list_indexes()?
|
||||||
|
.into_iter()
|
||||||
|
.find(|i| i.name == name.as_ref()))
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn http_payload_size_limit(&self) -> usize {
|
pub fn http_payload_size_limit(&self) -> usize {
|
||||||
self.options.http_payload_size_limit.get_bytes() as usize
|
self.options.http_payload_size_limit.get_bytes() as usize
|
||||||
|
@ -28,6 +28,13 @@ impl fmt::Display for ResponseError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove this when implementing actual error handling
|
||||||
|
impl From<anyhow::Error> for ResponseError {
|
||||||
|
fn from(other: anyhow::Error) -> ResponseError {
|
||||||
|
ResponseError { inner: Box::new(Error::NotFound(other.to_string())) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<Error> for ResponseError {
|
impl From<Error> for ResponseError {
|
||||||
fn from(error: Error) -> ResponseError {
|
fn from(error: Error) -> ResponseError {
|
||||||
ResponseError { inner: Box::new(error) }
|
ResponseError { inner: Box::new(error) }
|
||||||
|
@ -83,15 +83,6 @@ async fn get_all_documents(
|
|||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
//fn find_primary_key(document: &IndexMap<String, Value>) -> Option<String> {
|
|
||||||
//for key in document.keys() {
|
|
||||||
//if key.to_lowercase().contains("id") {
|
|
||||||
//return Some(key.to_string());
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
//None
|
|
||||||
//}
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||||
struct UpdateDocumentsQuery {
|
struct UpdateDocumentsQuery {
|
||||||
@ -150,6 +141,7 @@ async fn add_documents_default(
|
|||||||
_params: web::Query<UpdateDocumentsQuery>,
|
_params: web::Query<UpdateDocumentsQuery>,
|
||||||
_body: web::Json<Vec<Document>>,
|
_body: web::Json<Vec<Document>>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
|
error!("Unknown document type");
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,10 +37,18 @@ async fn list_indexes(data: web::Data<Data>) -> Result<HttpResponse, ResponseErr
|
|||||||
|
|
||||||
#[get("/indexes/{index_uid}", wrap = "Authentication::Private")]
|
#[get("/indexes/{index_uid}", wrap = "Authentication::Private")]
|
||||||
async fn get_index(
|
async fn get_index(
|
||||||
_data: web::Data<Data>,
|
data: web::Data<Data>,
|
||||||
_path: web::Path<IndexParam>,
|
path: web::Path<IndexParam>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
todo!()
|
match data.index(&path.index_uid)? {
|
||||||
|
Some(meta) => {
|
||||||
|
let json = serde_json::to_string(&meta).unwrap();
|
||||||
|
Ok(HttpResponse::Ok().body(json))
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
Loading…
Reference in New Issue
Block a user