Rename attributes for faceting into filterable attributes

This commit is contained in:
Clémentine Urquizar 2021-06-03 23:47:16 +02:00
parent 7009906d55
commit 88bf867a3e
No known key found for this signature in database
GPG key ID: D8E7CC7422E77E1A
7 changed files with 22 additions and 22 deletions

View file

@ -87,7 +87,7 @@ impl Index {
Ok(Settings {
displayed_attributes: Some(displayed_attributes),
searchable_attributes: Some(searchable_attributes),
attributes_for_faceting: Some(Some(faceted_attributes)),
filterable_attributes: Some(Some(faceted_attributes)),
ranking_rules: Some(Some(criteria)),
stop_words: Some(Some(stop_words)),
distinct_attribute: Some(distinct_field),

View file

@ -51,7 +51,7 @@ pub struct Settings<T> {
deserialize_with = "deserialize_some",
skip_serializing_if = "Option::is_none"
)]
pub attributes_for_faceting: Option<Option<HashSet<String>>>,
pub filterable_attributes: Option<Option<HashSet<String>>>,
#[serde(
default,
@ -81,7 +81,7 @@ impl Settings<Checked> {
Settings {
displayed_attributes: Some(None),
searchable_attributes: Some(None),
attributes_for_faceting: Some(None),
filterable_attributes: Some(None),
ranking_rules: Some(None),
stop_words: Some(None),
distinct_attribute: Some(None),
@ -93,7 +93,7 @@ impl Settings<Checked> {
let Self {
displayed_attributes,
searchable_attributes,
attributes_for_faceting,
filterable_attributes,
ranking_rules,
stop_words,
distinct_attribute,
@ -103,7 +103,7 @@ impl Settings<Checked> {
Settings {
displayed_attributes,
searchable_attributes,
attributes_for_faceting,
filterable_attributes,
ranking_rules,
stop_words,
distinct_attribute,
@ -139,7 +139,7 @@ impl Settings<Unchecked> {
Settings {
displayed_attributes,
searchable_attributes,
attributes_for_faceting: self.attributes_for_faceting,
filterable_attributes: self.filterable_attributes,
ranking_rules: self.ranking_rules,
stop_words: self.stop_words,
distinct_attribute: self.distinct_attribute,
@ -252,7 +252,7 @@ impl Index {
}
}
if let Some(ref facet_types) = settings.attributes_for_faceting {
if let Some(ref facet_types) = settings.filterable_attributes {
let facet_types = facet_types.clone().unwrap_or_else(HashSet::new);
builder.set_filterable_fields(facet_types);
}
@ -329,7 +329,7 @@ mod test {
let settings = Settings {
displayed_attributes: Some(Some(vec![String::from("hello")])),
searchable_attributes: Some(Some(vec![String::from("hello")])),
attributes_for_faceting: None,
filterable_attributes: None,
ranking_rules: None,
stop_words: None,
distinct_attribute: None,
@ -348,7 +348,7 @@ mod test {
let settings = Settings {
displayed_attributes: Some(Some(vec![String::from("*")])),
searchable_attributes: Some(Some(vec![String::from("hello"), String::from("*")])),
attributes_for_faceting: None,
filterable_attributes: None,
ranking_rules: None,
stop_words: None,
distinct_attribute: None,

View file

@ -73,7 +73,7 @@ struct Settings {
#[serde(default, deserialize_with = "deserialize_some")]
pub synonyms: Option<Option<BTreeMap<String, Vec<String>>>>,
#[serde(default, deserialize_with = "deserialize_some")]
pub attributes_for_faceting: Option<Option<Vec<String>>>,
pub filterable_attributes: Option<Option<Vec<String>>>,
}
fn load_index(
@ -145,7 +145,7 @@ impl From<Settings> for index_controller::Settings<Unchecked> {
// representing the name of the faceted field + the type of the field. Since the type
// was not known in the V1 of the dump we are just going to assume everything is a
// String
attributes_for_faceting: settings.attributes_for_faceting.map(|o| o.map(|vec| vec.into_iter().collect())),
filterable_attributes: settings.filterable_attributes.map(|o| o.map(|vec| vec.into_iter().collect())),
// we need to convert the old `Vec<String>` into a `BTreeSet<String>`
ranking_rules: settings.ranking_rules.map(|o| o.map(|vec| vec.into_iter().filter_map(|criterion| {
match criterion.as_str() {

View file

@ -74,9 +74,9 @@ macro_rules! make_setting_route {
}
make_setting_route!(
"/indexes/{index_uid}/settings/attributes-for-faceting",
"/indexes/{index_uid}/settings/filterable-attributes",
std::collections::HashSet<String>,
attributes_for_faceting
filterable_attributes
);
make_setting_route!(
@ -126,7 +126,7 @@ macro_rules! create_services {
}
create_services!(
attributes_for_faceting,
filterable_attributes,
displayed_attributes,
searchable_attributes,
distinct_attribute,