mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-02-05 01:53:28 +01:00
Facet leveled field id bulk update (old)
This commit is contained in:
parent
0ee69ea07b
commit
2d7971bd40
@ -10,11 +10,12 @@ use roaring::RoaringBitmap;
|
|||||||
use rstar::RTree;
|
use rstar::RTree;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::attribute_patterns::PatternMatch;
|
||||||
use crate::constants::{RESERVED_GEO_FIELD_NAME, RESERVED_VECTORS_FIELD_NAME};
|
use crate::constants::{RESERVED_GEO_FIELD_NAME, RESERVED_VECTORS_FIELD_NAME};
|
||||||
use crate::documents::PrimaryKey;
|
use crate::documents::PrimaryKey;
|
||||||
use crate::error::{InternalError, UserError};
|
use crate::error::{InternalError, UserError};
|
||||||
use crate::fields_ids_map::FieldsIdsMap;
|
use crate::fields_ids_map::FieldsIdsMap;
|
||||||
use crate::filterable_fields::matching_field_ids;
|
use crate::filterable_fields::{match_pattern_by_features, matching_field_ids};
|
||||||
use crate::heed_codec::facet::{
|
use crate::heed_codec::facet::{
|
||||||
FacetGroupKeyCodec, FacetGroupValueCodec, FieldDocIdFacetF64Codec, FieldDocIdFacetStringCodec,
|
FacetGroupKeyCodec, FacetGroupValueCodec, FieldDocIdFacetF64Codec, FieldDocIdFacetStringCodec,
|
||||||
FieldIdCodec, OrderedF64Codec,
|
FieldIdCodec, OrderedF64Codec,
|
||||||
@ -895,6 +896,27 @@ impl Index {
|
|||||||
Ok(geo_filter)
|
Ok(geo_filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the field ids of the fields that are filterable using the ordering operators or are sortable.
|
||||||
|
pub fn facet_leveled_field_ids(&self, rtxn: &RoTxn<'_>) -> Result<Vec<FieldId>> {
|
||||||
|
let filterable_fields = self.filterable_fields(rtxn)?;
|
||||||
|
let sortable_fields = self.sortable_fields(rtxn)?;
|
||||||
|
let fields_ids_map = self.fields_ids_map(rtxn)?;
|
||||||
|
|
||||||
|
let mut fields_ids = Vec::new();
|
||||||
|
for (field_id, field_name) in fields_ids_map.iter() {
|
||||||
|
if match_pattern_by_features(field_name, &filterable_fields, &|features| {
|
||||||
|
features.is_filterable_order()
|
||||||
|
}) == PatternMatch::Match
|
||||||
|
{
|
||||||
|
fields_ids.push(field_id);
|
||||||
|
} else if sortable_fields.contains(field_name) {
|
||||||
|
fields_ids.push(field_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(fields_ids)
|
||||||
|
}
|
||||||
|
|
||||||
// /// Returns the faceted fields names.
|
// /// Returns the faceted fields names.
|
||||||
// pub fn faceted_fields(&self, rtxn: &RoTxn<'_>) -> heed::Result<HashSet<String>> {
|
// pub fn faceted_fields(&self, rtxn: &RoTxn<'_>) -> heed::Result<HashSet<String>> {
|
||||||
// Ok(self
|
// Ok(self
|
||||||
|
@ -156,8 +156,7 @@ impl<'i> FacetsUpdate<'i> {
|
|||||||
|
|
||||||
// See self::comparison_bench::benchmark_facet_indexing
|
// See self::comparison_bench::benchmark_facet_indexing
|
||||||
if self.data_size >= (self.database.len(wtxn)? / 500) {
|
if self.data_size >= (self.database.len(wtxn)? / 500) {
|
||||||
let field_ids =
|
let field_ids = self.index.facet_leveled_field_ids(wtxn)?;
|
||||||
self.index.faceted_fields_ids(wtxn)?.iter().copied().collect::<Vec<_>>();
|
|
||||||
let bulk_update = FacetsUpdateBulk::new(
|
let bulk_update = FacetsUpdateBulk::new(
|
||||||
self.index,
|
self.index,
|
||||||
field_ids,
|
field_ids,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user