Apply PR requests related to settings API

This commit is contained in:
ManyTheFish 2025-03-05 12:05:40 +01:00
parent 5fa4b5c50a
commit 63e753bde0
7 changed files with 44 additions and 43 deletions

View file

@ -8,7 +8,7 @@ use crate::is_faceted_by;
#[repr(transparent)]
#[serde(transparent)]
pub struct AttributePatterns {
#[schema(value_type = Vec<String>)]
#[schema(example = json!(["title", "overview_*", "release_date"]))]
pub patterns: Vec<String>,
}
@ -121,7 +121,8 @@ pub fn match_distinct_field(distinct_field: Option<&str>, field: &str) -> Patter
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PatternMatch {
/// The field is a parent of the of a nested field that matches the pattern
/// The field is a parent of a nested field that matches the pattern
/// For example, the field is `toto`, and the pattern is `toto.titi`
Parent,
/// The field matches the pattern
Match,

View file

@ -50,7 +50,7 @@ impl FilterableAttributesRule {
#[serde(deny_unknown_fields, rename_all = "camelCase")]
#[deserr(rename_all = camelCase, deny_unknown_fields)]
pub struct FilterableAttributesPatterns {
pub patterns: AttributePatterns,
pub attribute_patterns: AttributePatterns,
#[serde(default)]
#[deserr(default)]
pub features: FilterableAttributesFeatures,
@ -58,15 +58,15 @@ pub struct FilterableAttributesPatterns {
impl FilterableAttributesPatterns {
pub fn match_str(&self, field: &str) -> PatternMatch {
self.patterns.match_str(field)
self.attribute_patterns.match_str(field)
}
pub fn features(&self) -> FilterableAttributesFeatures {
self.features.clone()
self.features
}
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, Deserr, ToSchema)]
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Copy, Debug, Deserr, ToSchema)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
#[deserr(rename_all = camelCase, deny_unknown_fields)]
#[derive(Default)]
@ -143,7 +143,7 @@ impl<E: DeserializeError> Deserr<E> for FilterableAttributesRule {
}
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, Deserr, ToSchema)]
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Copy, Debug, Deserr, ToSchema)]
pub struct FilterFeatures {
equality: bool,
comparison: bool,

View file

@ -868,12 +868,12 @@ impl Index {
pub(crate) fn put_filterable_attributes_rules(
&self,
wtxn: &mut RwTxn<'_>,
#[allow(clippy::ptr_arg)] fields: &Vec<FilterableAttributesRule>,
fields: &[FilterableAttributesRule],
) -> heed::Result<()> {
self.main.remap_types::<Str, SerdeJson<_>>().put(
wtxn,
main_key::FILTERABLE_FIELDS_KEY,
fields,
&fields,
)
}