mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
implement get single index
This commit is contained in:
parent
281a445998
commit
ced32afd9f
@ -86,12 +86,8 @@ impl Data {
|
|||||||
self.index_controller.list_indexes().await
|
self.index_controller.list_indexes().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn index(&self, name: impl AsRef<str>) -> anyhow::Result<Option<IndexMetadata>> {
|
pub async fn index(&self, name: impl AsRef<str>) -> anyhow::Result<Option<IndexMetadata>> {
|
||||||
todo!()
|
self.index_controller.get_index(name.as_ref().to_string()).await
|
||||||
//Ok(self
|
|
||||||
//.list_indexes()?
|
|
||||||
//.into_iter()
|
|
||||||
//.find(|i| i.uid == name.as_ref()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_index(&self, name: impl AsRef<str>, primary_key: Option<impl AsRef<str>>) -> anyhow::Result<IndexMetadata> {
|
pub async fn create_index(&self, name: impl AsRef<str>, primary_key: Option<impl AsRef<str>>) -> anyhow::Result<IndexMetadata> {
|
||||||
|
@ -239,6 +239,18 @@ impl IndexController {
|
|||||||
let result = self.index_handle.search(uuid, query).await?;
|
let result = self.index_handle.search(uuid, query).await?;
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_index(&self, name: String) -> anyhow::Result<Option<IndexMetadata>> {
|
||||||
|
let uuid = self.uuid_resolver.resolve(name.clone()).await?;
|
||||||
|
if let Some(uuid) = uuid {
|
||||||
|
let result = self.index_handle
|
||||||
|
.get_index_meta(uuid)
|
||||||
|
.await?
|
||||||
|
.map(|meta| IndexMetadata { name, meta });
|
||||||
|
return Ok(result)
|
||||||
|
}
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_arc_ownership_blocking<T>(mut item: Arc<T>) -> T {
|
pub async fn get_arc_ownership_blocking<T>(mut item: Arc<T>) -> T {
|
||||||
|
@ -37,7 +37,7 @@ 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> {
|
||||||
match data.index(&path.index_uid)? {
|
match data.index(&path.index_uid).await? {
|
||||||
Some(meta) => {
|
Some(meta) => {
|
||||||
let json = serde_json::to_string(&meta).unwrap();
|
let json = serde_json::to_string(&meta).unwrap();
|
||||||
Ok(HttpResponse::Ok().body(json))
|
Ok(HttpResponse::Ok().body(json))
|
||||||
|
Loading…
Reference in New Issue
Block a user