mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-10-29 06:56:45 +00:00
Refactor the FieldIdMapWithMetadata
**Changes:** The FieldIdMapWithMetadata structure now stores more information about fields. The metadata_for_field function computes all the needed information relying on the user provided data instead of the enriched data (searchable/sortable) which may solve an indexing bug on sortable attributes that was not matching the nested fields. The FieldIdMapWithMetadata structure was duplicated in the embeddings as FieldsIdsMapWithMetadata, so the FieldsIdsMapWithMetadata has been removed in favor of FieldIdMapWithMetadata. The Facet distribution is now relying on the FieldIdMapWithMetadata with metadata to match is a field can be faceted. **Impact:** - searchable attributes matching - searchable attributes weight computation - sortable attributes matching - faceted fields matching - prompt computing - facet distribution
This commit is contained in:
@@ -7,14 +7,14 @@ use liquid::model::{
|
||||
};
|
||||
use liquid::{ObjectView, ValueView};
|
||||
|
||||
use super::{FieldMetadata, FieldsIdsMapWithMetadata};
|
||||
use crate::fields_ids_map::metadata::{FieldIdMapWithMetadata, Metadata};
|
||||
use crate::GlobalFieldsIdsMap;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct FieldValue<'a, D: ObjectView> {
|
||||
name: &'a str,
|
||||
document: &'a D,
|
||||
metadata: FieldMetadata,
|
||||
metadata: Metadata,
|
||||
}
|
||||
|
||||
impl<'a, D: ObjectView> ValueView for FieldValue<'a, D> {
|
||||
@@ -67,7 +67,10 @@ impl<'a, D: ObjectView> FieldValue<'a, D> {
|
||||
}
|
||||
|
||||
pub fn is_searchable(&self) -> &bool {
|
||||
&self.metadata.searchable
|
||||
match self.metadata.is_searchable() {
|
||||
true => &true,
|
||||
false => &false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
@@ -125,15 +128,11 @@ pub struct BorrowedFields<'a, 'map, D: ObjectView> {
|
||||
}
|
||||
|
||||
impl<'a, D: ObjectView> OwnedFields<'a, D> {
|
||||
pub fn new(document: &'a D, field_id_map: &'a FieldsIdsMapWithMetadata<'a>) -> Self {
|
||||
pub fn new(document: &'a D, field_id_map: &'a FieldIdMapWithMetadata) -> Self {
|
||||
Self(
|
||||
std::iter::repeat(document)
|
||||
.zip(field_id_map.iter())
|
||||
.map(|(document, (fid, name))| FieldValue {
|
||||
document,
|
||||
name,
|
||||
metadata: field_id_map.metadata(fid).unwrap_or_default(),
|
||||
})
|
||||
.map(|(document, (_fid, name, metadata))| FieldValue { document, name, metadata })
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
@@ -187,7 +186,7 @@ impl<'a, 'map, D: ObjectView> ArrayView for BorrowedFields<'a, 'map, D> {
|
||||
let fv = self.doc_alloc.alloc(FieldValue {
|
||||
name: self.doc_alloc.alloc_str(&k),
|
||||
document: self.document,
|
||||
metadata: FieldMetadata { searchable: metadata.searchable },
|
||||
metadata,
|
||||
});
|
||||
fv as _
|
||||
}))
|
||||
@@ -207,7 +206,7 @@ impl<'a, 'map, D: ObjectView> ArrayView for BorrowedFields<'a, 'map, D> {
|
||||
let fv = self.doc_alloc.alloc(FieldValue {
|
||||
name: self.doc_alloc.alloc_str(&key),
|
||||
document: self.document,
|
||||
metadata: FieldMetadata { searchable: metadata.searchable },
|
||||
metadata,
|
||||
});
|
||||
Some(fv as _)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user