diff --git a/crates/milli/src/attribute_patterns.rs b/crates/milli/src/attribute_patterns.rs index c7045c68e..00caa2a6d 100644 --- a/crates/milli/src/attribute_patterns.rs +++ b/crates/milli/src/attribute_patterns.rs @@ -55,7 +55,7 @@ fn match_pattern(pattern: &str, str: &str) -> PatternMatch { if pattern == "*" { return PatternMatch::Match; } else if pattern.starts_with('*') && pattern.ends_with('*') { - // If the starts and ends with a wildcard, return Match if the string contains the pattern without the wildcards + // If the pattern starts and ends with a wildcard, return Match if the string contains the pattern without the wildcards if str.contains(&pattern[1..pattern.len() - 1]) { return PatternMatch::Match; } diff --git a/crates/milli/src/fieldids_weights_map.rs b/crates/milli/src/fieldids_weights_map.rs index 57c99f77f..0c57ba109 100644 --- a/crates/milli/src/fieldids_weights_map.rs +++ b/crates/milli/src/fieldids_weights_map.rs @@ -43,11 +43,6 @@ impl FieldidsWeightsMap { self.map.get(&fid).copied() } - /// Returns highest weight contained in the map if any. - pub fn max_weight(&self) -> Option { - self.map.values().copied().max() - } - /// Return an iterator visiting all field ids in arbitrary order. pub fn ids(&self) -> impl Iterator + '_ { self.map.keys().copied() diff --git a/crates/milli/src/search/new/ranking_rule_graph/fid/mod.rs b/crates/milli/src/search/new/ranking_rule_graph/fid/mod.rs index e55f1febf..5f0c37cc3 100644 --- a/crates/milli/src/search/new/ranking_rule_graph/fid/mod.rs +++ b/crates/milli/src/search/new/ranking_rule_graph/fid/mod.rs @@ -92,10 +92,7 @@ impl RankingRuleGraphTrait for FidGraph { } // always lookup the max_fid if we don't already and add an artificial condition for max scoring - let max_weight = ctx - .index - .max_searchable_attribute_weight(ctx.txn)? - .or_else(|| weights_map.max_weight()); + let max_weight = ctx.index.max_searchable_attribute_weight(ctx.txn)?; if let Some(max_weight) = max_weight { if current_max_weight < max_weight { diff --git a/crates/milli/src/update/index_documents/transform.rs b/crates/milli/src/update/index_documents/transform.rs index b2ee21cbf..769e86b39 100644 --- a/crates/milli/src/update/index_documents/transform.rs +++ b/crates/milli/src/update/index_documents/transform.rs @@ -745,12 +745,14 @@ impl<'a, 'i> Transform<'a, 'i> { } else { let facet_operation = necessary_faceted_field(id); let searchable_operation = settings_diff.reindex_searchable_id(id); - let operation = facet_operation - // TODO: replace `zip.map` with `zip_with` once stable - .zip(searchable_operation) - .map(|(op1, op2)| op1.merge(op2)) - .or(facet_operation) - .or(searchable_operation); + let operation = match (facet_operation, searchable_operation) { + (Some(facet_operation), Some(searchable_operation)) => { + Some(facet_operation.merge(searchable_operation)) + } + (Some(operation), None) | (None, Some(operation)) => Some(operation), + (None, None) => None, + }; + if let Some(operation) = operation { operations.insert(id, operation); obkv_writer.insert(id, val)?; diff --git a/crates/milli/src/update/new/extract/faceted/extract_facets.rs b/crates/milli/src/update/new/extract/faceted/extract_facets.rs index 3201e23f9..05fcdf72a 100644 --- a/crates/milli/src/update/new/extract/faceted/extract_facets.rs +++ b/crates/milli/src/update/new/extract/faceted/extract_facets.rs @@ -30,10 +30,10 @@ pub struct FacetedExtractorData<'a, 'b> { sender: &'a FieldIdDocidFacetSender<'a, 'b>, grenad_parameters: &'a GrenadParameters, buckets: usize, - filterable_attributes: Vec, - sortable_fields: HashSet, - asc_desc_fields: HashSet, - distinct_field: Option, + filterable_attributes: &'a [FilterableAttributesRule], + sortable_fields: &'a HashSet, + asc_desc_fields: &'a HashSet, + distinct_field: &'a Option, is_geo_enabled: bool, } @@ -478,10 +478,10 @@ impl FacetedDocidsExtractor { grenad_parameters: indexing_context.grenad_parameters, buckets: rayon::current_num_threads(), sender, - filterable_attributes, - sortable_fields, - asc_desc_fields, - distinct_field, + filterable_attributes: &filterable_attributes, + sortable_fields: &sortable_fields, + asc_desc_fields: &asc_desc_fields, + distinct_field: &distinct_field, is_geo_enabled, }; extract(