mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 09:04:59 +08:00
fix deserializer
This commit is contained in:
parent
086020e543
commit
ac7226bb27
@ -55,6 +55,7 @@ pub struct Deserializer<'a> {
|
|||||||
pub documents_fields: DocumentsFields,
|
pub documents_fields: DocumentsFields,
|
||||||
pub schema: &'a Schema,
|
pub schema: &'a Schema,
|
||||||
pub fields: Option<&'a HashSet<FieldId>>,
|
pub fields: Option<&'a HashSet<FieldId>>,
|
||||||
|
pub displayed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de, 'a, 'b> de::Deserializer<'de> for &'b mut Deserializer<'a> {
|
impl<'de, 'a, 'b> de::Deserializer<'de> for &'b mut Deserializer<'a> {
|
||||||
@ -93,7 +94,7 @@ impl<'de, 'a, 'b> de::Deserializer<'de> for &'b mut Deserializer<'a> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let is_displayed = self.schema.is_displayed(attr);
|
let is_displayed = self.schema.is_displayed(attr);
|
||||||
if is_displayed && self.fields.map_or(true, |f| f.contains(&attr)) {
|
if !self.displayed || (is_displayed && self.fields.map_or(true, |f| f.contains(&attr))) {
|
||||||
if let Some(attribute_name) = self.schema.name(attr) {
|
if let Some(attribute_name) = self.schema.name(attr) {
|
||||||
let cursor = Cursor::new(value.to_owned());
|
let cursor = Cursor::new(value.to_owned());
|
||||||
let ioread = SerdeJsonIoRead::new(cursor);
|
let ioread = SerdeJsonIoRead::new(cursor);
|
||||||
|
@ -243,6 +243,7 @@ impl Index {
|
|||||||
documents_fields: self.documents_fields,
|
documents_fields: self.documents_fields,
|
||||||
schema: &schema,
|
schema: &schema,
|
||||||
fields: attributes.as_ref(),
|
fields: attributes.as_ref(),
|
||||||
|
displayed: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Option::<T>::deserialize(&mut deserializer)?)
|
Ok(Option::<T>::deserialize(&mut deserializer)?)
|
||||||
|
@ -197,6 +197,7 @@ pub fn apply_addition<'a, 'b>(
|
|||||||
documents_fields: index.documents_fields,
|
documents_fields: index.documents_fields,
|
||||||
schema: &schema,
|
schema: &schema,
|
||||||
fields: None,
|
fields: None,
|
||||||
|
displayed: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let old_document = Option::<HashMap<String, Value>>::deserialize(&mut deserializer)?;
|
let old_document = Option::<HashMap<String, Value>>::deserialize(&mut deserializer)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user