diff --git a/src/update/index_documents/mod.rs b/src/update/index_documents/mod.rs index 9869f0edc..25264e7ae 100644 --- a/src/update/index_documents/mod.rs +++ b/src/update/index_documents/mod.rs @@ -745,7 +745,7 @@ mod tests { let mut wtxn = index.write_txn().unwrap(); let content = &br#"[ { "name": "kevin" }, - { "name": "kevina", "id": "21" }, + { "name": "kevina", "id": 21 }, { "name": "benoit" } ]"#[..]; let mut builder = IndexDocuments::new(&mut wtxn, &index); diff --git a/src/update/index_documents/store.rs b/src/update/index_documents/store.rs index fba946820..7c1896ee5 100644 --- a/src/update/index_documents/store.rs +++ b/src/update/index_documents/store.rs @@ -309,7 +309,19 @@ impl Store { } for (attr, content) in document.iter() { - let content: Cow = serde_json::from_slice(content).unwrap(); + use serde_json::Value; + let content: Cow = match serde_json::from_slice(content) { + Ok(string) => string, + Err(_) => match serde_json::from_slice(content)? { + Value::Null => continue, + Value::Bool(boolean) => Cow::Owned(boolean.to_string()), + Value::Number(number) => Cow::Owned(number.to_string()), + Value::String(string) => Cow::Owned(string), + Value::Array(_array) => continue, + Value::Object(_object) => continue, + } + }; + for (pos, token) in simple_tokenizer(&content).filter_map(only_token).enumerate().take(MAX_POSITION) { let word = token.to_lowercase(); let position = (attr as usize * MAX_POSITION + pos) as u32;