mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-19 17:38:28 +08:00
fix distinct attribute returning id instead of name
This commit is contained in:
parent
4ad4d7cf34
commit
feb12a581e
@ -110,14 +110,14 @@ async fn get_all(
|
|||||||
|
|
||||||
println!("{:?}", attributes_for_faceting);
|
println!("{:?}", attributes_for_faceting);
|
||||||
|
|
||||||
let searchable_attributes = schema.clone().map(|s| {
|
let searchable_attributes = schema.as_ref().map(|s| {
|
||||||
s.indexed_name()
|
s.indexed_name()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| s.to_string())
|
.map(|s| s.to_string())
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
});
|
});
|
||||||
|
|
||||||
let displayed_attributes = schema.clone().map(|s| {
|
let displayed_attributes = schema.as_ref().map(|s| {
|
||||||
s.displayed_name()
|
s.displayed_name()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| s.to_string())
|
.map(|s| s.to_string())
|
||||||
@ -253,7 +253,12 @@ async fn get_distinct(
|
|||||||
.open_index(&path.index_uid)
|
.open_index(&path.index_uid)
|
||||||
.ok_or(Error::index_not_found(&path.index_uid))?;
|
.ok_or(Error::index_not_found(&path.index_uid))?;
|
||||||
let reader = data.db.main_read_txn()?;
|
let reader = data.db.main_read_txn()?;
|
||||||
let distinct_attribute = index.main.distinct_attribute(&reader)?;
|
let distinct_attribute_id = index.main.distinct_attribute(&reader)?;
|
||||||
|
let schema = index.main.schema(&reader)?;
|
||||||
|
let distinct_attribute = match (schema, distinct_attribute_id) {
|
||||||
|
(Some(schema), Some(id)) => schema.name(id).map(str::to_string),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
Ok(HttpResponse::Ok().json(distinct_attribute))
|
Ok(HttpResponse::Ok().json(distinct_attribute))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user