mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Rename index_name to index_uids
This commit is contained in:
parent
39e2b73718
commit
e97e13ce9f
4 changed files with 47 additions and 4 deletions
|
@ -29,11 +29,54 @@ pub async fn list_indexes(ctx: Context<Data>) -> SResult<Response> {
|
|||
let list = ctx
|
||||
.state()
|
||||
.db
|
||||
.indexes_names()
|
||||
.indexes_uids()
|
||||
.map_err(ResponseError::internal)?;
|
||||
Ok(tide::response::json(list))
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
struct GetIndexResponse {
|
||||
name: String,
|
||||
uid: String,
|
||||
schema: Option<SchemaBody>,
|
||||
created_at: DateTime<Utc>,
|
||||
updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
pub async fn get_index(ctx: Context<Data>) -> SResult<Response> {
|
||||
ctx.is_allowed(IndexesRead)?;
|
||||
|
||||
let index = ctx.index()?;
|
||||
|
||||
let env = &ctx.state().db.env;
|
||||
let mut reader = env.read_txn().map_err(ResponseError::internal)?;
|
||||
|
||||
let uid = ctx.url_param("index")?.to_string();
|
||||
let name = index.main.name(&mut reader)
|
||||
.map_err(ResponseError::internal)?
|
||||
.ok_or(ResponseError::internal("Name not found"))?;
|
||||
let schema = index.main.schema(&mut reader)
|
||||
.map_err(ResponseError::internal)?
|
||||
.map(|schema| SchemaBody::from(schema));
|
||||
let created_at = index.main.created_at(&mut reader)
|
||||
.map_err(ResponseError::internal)?
|
||||
.ok_or(ResponseError::internal("Created date not found"))?;
|
||||
let updated_at = index.main.updated_at(&mut reader)
|
||||
.map_err(ResponseError::internal)?
|
||||
.ok_or(ResponseError::internal("Updated date not found"))?;
|
||||
|
||||
let response_body = GetIndexResponse {
|
||||
name,
|
||||
uid,
|
||||
schema,
|
||||
created_at,
|
||||
updated_at,
|
||||
};
|
||||
|
||||
Ok(tide::response::json(response_body))
|
||||
}
|
||||
|
||||
pub async fn get_index_schema(ctx: Context<Data>) -> SResult<Response> {
|
||||
ctx.is_allowed(IndexesRead)?;
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ pub async fn search_multi_index(mut ctx: Context<Data>) -> SResult<Response> {
|
|||
index_list = ctx
|
||||
.state()
|
||||
.db
|
||||
.indexes_names()
|
||||
.indexes_uids()
|
||||
.map_err(ResponseError::internal)?
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
|
|
@ -72,7 +72,7 @@ pub async fn get_stats(ctx: Context<Data>) -> SResult<Response> {
|
|||
|
||||
let mut index_list = HashMap::new();
|
||||
|
||||
if let Ok(indexes_set) = ctx.state().db.indexes_names() {
|
||||
if let Ok(indexes_set) = ctx.state().db.indexes_uids() {
|
||||
for index_uid in indexes_set {
|
||||
let db = &ctx.state().db;
|
||||
let env = &db.env;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue