mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
fix bug
This commit is contained in:
parent
1639a7338d
commit
dc2e5ceed2
8 changed files with 26 additions and 99 deletions
|
@ -246,7 +246,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_facet_key() {
|
||||
let mut schema = Schema::new();
|
||||
let id = schema.insert_and_index("hello").unwrap();
|
||||
let id = schema.register_field("hello").unwrap();
|
||||
let facet_list = [schema.id("hello").unwrap()];
|
||||
assert_eq!(
|
||||
FacetKey::from_str("hello:12", &schema, &facet_list).unwrap(),
|
||||
|
@ -287,7 +287,7 @@ mod test {
|
|||
fn test_parse_facet_array() {
|
||||
use either::Either::{Left, Right};
|
||||
let mut schema = Schema::new();
|
||||
let _id = schema.insert_and_index("hello").unwrap();
|
||||
let _id = schema.register_field("hello").unwrap();
|
||||
let facet_list = [schema.id("hello").unwrap()];
|
||||
assert_eq!(
|
||||
FacetFilter::from_str("[[\"hello:12\"]]", &schema, &facet_list).unwrap(),
|
||||
|
|
|
@ -94,6 +94,8 @@ impl<'de, 'a, 'b> de::Deserializer<'de> for &'b mut Deserializer<'a> {
|
|||
};
|
||||
|
||||
let is_displayed = self.schema.is_displayed(attr);
|
||||
// Check if displayed fields were requested, if yes, return only displayed fields,
|
||||
// else return all fields
|
||||
if !self.displayed || (is_displayed && self.fields.map_or(true, |f| f.contains(&attr))) {
|
||||
if let Some(attribute_name) = self.schema.name(attr) {
|
||||
let cursor = Cursor::new(value.to_owned());
|
||||
|
|
|
@ -201,14 +201,12 @@ pub fn apply_addition<'a, 'b>(
|
|||
};
|
||||
|
||||
let old_document = Option::<HashMap<String, Value>>::deserialize(&mut deserializer)?;
|
||||
println!("old document: {:#?}", old_document);
|
||||
if let Some(old_document) = old_document {
|
||||
for (key, value) in old_document {
|
||||
document.entry(key).or_insert(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("new document: {:#?}", document);
|
||||
documents_additions.insert(internal_docid, document);
|
||||
}
|
||||
|
||||
|
@ -231,7 +229,7 @@ pub fn apply_addition<'a, 'b>(
|
|||
for (document_id, document) in &documents_additions {
|
||||
// For each key-value pair in the document.
|
||||
for (attribute, value) in document {
|
||||
let field_id = schema.insert_and_index(&attribute)?;
|
||||
let field_id = schema.register_field(&attribute)?;
|
||||
index_document(
|
||||
writer,
|
||||
index.documents_fields,
|
||||
|
|
|
@ -20,7 +20,6 @@ pub fn index_value<A>(
|
|||
) -> Option<usize>
|
||||
where A: AsRef<[u8]>,
|
||||
{
|
||||
println!("indexing value: {}", value);
|
||||
match value {
|
||||
Value::Null => None,
|
||||
Value::Bool(boolean) => {
|
||||
|
|
|
@ -70,11 +70,9 @@ pub fn apply_settings_update(
|
|||
|
||||
match settings.searchable_attributes.clone() {
|
||||
UpdateState::Update(v) => {
|
||||
println!("updating indexed attributes");
|
||||
if v.iter().any(|e| e == "*") || v.is_empty() {
|
||||
schema.set_all_fields_as_indexed();
|
||||
} else {
|
||||
println!("updating indexed");
|
||||
schema.update_indexed(v)?;
|
||||
}
|
||||
must_reindex = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue