mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
add ranking rules
This commit is contained in:
parent
66b64c1f80
commit
8617bcf8bd
@ -44,11 +44,17 @@ impl Index {
|
|||||||
.map(|(k, v)| (k, v.to_string()))
|
.map(|(k, v)| (k, v.to_string()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
let criteria = self
|
||||||
|
.criteria(&txn)?
|
||||||
|
.into_iter()
|
||||||
|
.map(|c| c.to_string())
|
||||||
|
.collect();
|
||||||
|
|
||||||
Ok(Settings {
|
Ok(Settings {
|
||||||
displayed_attributes: Some(Some(displayed_attributes)),
|
displayed_attributes: Some(Some(displayed_attributes)),
|
||||||
searchable_attributes: Some(Some(searchable_attributes)),
|
searchable_attributes: Some(Some(searchable_attributes)),
|
||||||
faceted_attributes: Some(Some(faceted_attributes)),
|
faceted_attributes: Some(Some(faceted_attributes)),
|
||||||
criteria: None,
|
ranking_rules: Some(Some(criteria)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ pub struct Settings {
|
|||||||
deserialize_with = "deserialize_some",
|
deserialize_with = "deserialize_some",
|
||||||
skip_serializing_if = "Option::is_none",
|
skip_serializing_if = "Option::is_none",
|
||||||
)]
|
)]
|
||||||
pub criteria: Option<Option<Vec<String>>>,
|
pub ranking_rules: Option<Option<Vec<String>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
@ -51,7 +51,7 @@ impl Settings {
|
|||||||
displayed_attributes: Some(None),
|
displayed_attributes: Some(None),
|
||||||
searchable_attributes: Some(None),
|
searchable_attributes: Some(None),
|
||||||
faceted_attributes: Some(None),
|
faceted_attributes: Some(None),
|
||||||
criteria: Some(None),
|
ranking_rules: Some(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ impl Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We transpose the settings JSON struct into a real setting update.
|
// We transpose the settings JSON struct into a real setting update.
|
||||||
if let Some(ref criteria) = settings.criteria {
|
if let Some(ref criteria) = settings.ranking_rules {
|
||||||
match criteria {
|
match criteria {
|
||||||
Some(criteria) => builder.set_criteria(criteria.clone()),
|
Some(criteria) => builder.set_criteria(criteria.clone()),
|
||||||
None => builder.reset_criteria(),
|
None => builder.reset_criteria(),
|
||||||
|
Loading…
Reference in New Issue
Block a user