mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-30 00:34:26 +01:00
Refacto
This commit is contained in:
parent
1ef061d92b
commit
9840b5c7fb
@ -235,9 +235,8 @@ fn parse_formatted_options(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if attr == "*" {
|
if attr == "*" {
|
||||||
let ids = displayed_ids.clone();
|
for id in displayed_ids {
|
||||||
for id in ids {
|
formatted_options.insert(*id, new_format);
|
||||||
formatted_options.insert(id, new_format);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -245,43 +244,40 @@ fn parse_formatted_options(
|
|||||||
if let Some(id) = fields_ids_map.id(&attr) {
|
if let Some(id) = fields_ids_map.id(&attr) {
|
||||||
formatted_options.insert(id, new_format);
|
formatted_options.insert(id, new_format);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
for attr in attr_to_crop {
|
for attr in attr_to_crop {
|
||||||
let mut attr_name = attr.clone();
|
let mut attr_name = attr.clone();
|
||||||
let mut attr_len = Some(query_crop_length);
|
let mut attr_len = query_crop_length;
|
||||||
|
|
||||||
if attr_name.contains(':') {
|
let mut split = attr_name.rsplitn(2, ':');
|
||||||
let mut split = attr_name.rsplit(':');
|
attr_name = match split.next().zip(split.next()) {
|
||||||
attr_len = match split.next() {
|
Some((len, name)) => {
|
||||||
Some(s) => s.parse::<usize>().ok(),
|
attr_len = len.parse().unwrap_or(query_crop_length);
|
||||||
None => None,
|
name.to_string()
|
||||||
|
},
|
||||||
|
None => attr_name,
|
||||||
};
|
};
|
||||||
attr_name = split.flat_map(|s| s.chars()).collect();
|
|
||||||
}
|
|
||||||
|
|
||||||
if attr_name == "*" {
|
if attr_name == "*" {
|
||||||
let ids = displayed_ids.clone();
|
for id in displayed_ids {
|
||||||
for id in ids {
|
formatted_options
|
||||||
let mut highlight = false;
|
.entry(*id)
|
||||||
if let Some(f) = formatted_options.get(&id) {
|
.and_modify(|f| f.crop = Some(attr_len))
|
||||||
highlight = f.highlight;
|
.or_insert(FormatOptions {
|
||||||
}
|
highlight: false,
|
||||||
formatted_options.insert(id, FormatOptions {
|
crop: Some(attr_len),
|
||||||
highlight,
|
|
||||||
crop: attr_len,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(id) = fields_ids_map.id(&attr_name) {
|
if let Some(id) = fields_ids_map.id(&attr_name) {
|
||||||
let mut highlight = false;
|
formatted_options
|
||||||
if let Some(f) = formatted_options.get(&id) {
|
.entry(id)
|
||||||
highlight = f.highlight;
|
.and_modify(|f| f.crop = Some(attr_len))
|
||||||
}
|
.or_insert(FormatOptions {
|
||||||
formatted_options.insert(id, FormatOptions {
|
highlight: false,
|
||||||
highlight,
|
crop: Some(attr_len),
|
||||||
crop: attr_len,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user