mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Merge #5254
5254: Granular Filterable attribute settings r=ManyTheFish a=ManyTheFish # Related **Issue:** https://github.com/meilisearch/meilisearch/issues/5163 **PRD:** https://meilisearch.notion.site/API-usage-Settings-to-opt-out-indexing-features-filterableAttributes-1764b06b651f80aba8bdf359b2df3ca8 # Summary Change the `filterableAttributes` settings to let the user choose which facet feature he wants to activate or not. Deactivating a feature will avoid some database computation in the indexing process and save time and disk size. # Example `PATCH /indexes/:index_uid/settings` ```json { "filterableAttributes": [ { "patterns": [ "cattos", "doggos.age" ], "features": { "facetSearch": false, "filter": { "equality": true, "comparison": false } } } ] } ``` # Impact on the codebase - Settings API: - `/settings` - `/settings/filterable-attributes` - OpenAPI - may impact the LocalizedAttributesRules due to the AttributePatterns factorization - Database: - Filterable attributes format changed - Faceted field_ids are no more stored in the database - FieldIdsMap has no more unexisting fields - Search: - Search using filters - Facet search - `Attributes` ranking rule - Distinct attribute - Facet distribution - Settings reindexing: - searchable - facet - vector - geo - Document indexing: - searchable - facet - vector - geo - Dump import # Note for the reviewers The changes are huge and have been split in different commits with a dedicated explanation, I suggest reviewing the commit 1by1 Co-authored-by: ManyTheFish <many@meilisearch.com>
This commit is contained in:
commit
a2a86ef4e2
82 changed files with 4169 additions and 1661 deletions
|
@ -291,7 +291,7 @@ make_setting_routes!(
|
|||
{
|
||||
route: "/filterable-attributes",
|
||||
update_verb: put,
|
||||
value_type: std::collections::BTreeSet<String>,
|
||||
value_type: Vec<meilisearch_types::milli::FilterableAttributesRule>,
|
||||
err_type: meilisearch_types::deserr::DeserrJsonError<
|
||||
meilisearch_types::error::deserr_codes::InvalidSettingsFilterableAttributes,
|
||||
>,
|
||||
|
|
|
@ -8,6 +8,7 @@ use std::collections::{BTreeMap, BTreeSet, HashSet};
|
|||
use meilisearch_types::facet_values_sort::FacetValuesSort;
|
||||
use meilisearch_types::locales::{Locale, LocalizedAttributesRuleView};
|
||||
use meilisearch_types::milli::update::Setting;
|
||||
use meilisearch_types::milli::FilterableAttributesRule;
|
||||
use meilisearch_types::settings::{
|
||||
FacetingSettings, PaginationSettings, PrefixSearchSettings, ProximityPrecisionView,
|
||||
RankingRuleView, SettingEmbeddingSettings, TypoSettings,
|
||||
|
@ -89,6 +90,10 @@ impl Aggregate for SettingsAnalytics {
|
|||
filterable_attributes: FilterableAttributesAnalytics {
|
||||
total: new.filterable_attributes.total.or(self.filterable_attributes.total),
|
||||
has_geo: new.filterable_attributes.has_geo.or(self.filterable_attributes.has_geo),
|
||||
has_patterns: new
|
||||
.filterable_attributes
|
||||
.has_patterns
|
||||
.or(self.filterable_attributes.has_patterns),
|
||||
},
|
||||
distinct_attribute: DistinctAttributeAnalytics {
|
||||
set: self.distinct_attribute.set | new.distinct_attribute.set,
|
||||
|
@ -328,13 +333,19 @@ impl SortableAttributesAnalytics {
|
|||
pub struct FilterableAttributesAnalytics {
|
||||
pub total: Option<usize>,
|
||||
pub has_geo: Option<bool>,
|
||||
pub has_patterns: Option<bool>,
|
||||
}
|
||||
|
||||
impl FilterableAttributesAnalytics {
|
||||
pub fn new(setting: Option<&BTreeSet<String>>) -> Self {
|
||||
pub fn new(setting: Option<&Vec<FilterableAttributesRule>>) -> Self {
|
||||
Self {
|
||||
total: setting.as_ref().map(|filter| filter.len()),
|
||||
has_geo: setting.as_ref().map(|filter| filter.contains("_geo")),
|
||||
has_geo: setting
|
||||
.as_ref()
|
||||
.map(|filter| filter.iter().any(FilterableAttributesRule::has_geo)),
|
||||
has_patterns: setting.as_ref().map(|filter| {
|
||||
filter.iter().any(|rule| matches!(rule, FilterableAttributesRule::Pattern(_)))
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue