From 5e31d28759104bde84b45ccdd54bf9f70cfa5e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 3 Mar 2020 19:36:46 +0100 Subject: [PATCH] Fix the inference of the documents searchable fields --- meilisearch-core/Cargo.toml | 4 ++-- .../src/update/documents_addition.rs | 5 +++-- meilisearch-core/src/update/mod.rs | 16 ++++++++-------- meilisearch-http/src/routes/setting.rs | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/meilisearch-core/Cargo.toml b/meilisearch-core/Cargo.toml index 54d0efd3a..5a9288ce5 100644 --- a/meilisearch-core/Cargo.toml +++ b/meilisearch-core/Cargo.toml @@ -17,6 +17,7 @@ env_logger = "0.7.0" fst = { version = "0.3.5", default-features = false } hashbrown = { version = "0.6.0", features = ["serde"] } heed = "0.6.1" +indexmap = { version = "1.2.0", features = ["serde-1"] } intervaltree = "0.2.5" itertools = "0.8.2" levenshtein_automata = { version = "0.1.1", features = ["fst_automaton"] } @@ -26,19 +27,18 @@ meilisearch-tokenizer = { path = "../meilisearch-tokenizer", version = "0.8.4" } meilisearch-types = { path = "../meilisearch-types", version = "0.8.4" } once_cell = "1.2.0" ordered-float = { version = "1.0.2", features = ["serde"] } +regex = "1.3.1" sdset = "0.3.6" serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" siphasher = "0.3.1" slice-group-by = "0.2.6" zerocopy = "0.2.8" -regex = "1.3.1" [dev-dependencies] assert_matches = "1.3" criterion = "0.3" csv = "1.0.7" -indexmap = { version = "1.2.0", features = ["serde-1"] } jemallocator = "0.3.2" rustyline = { version = "5.0.0", default-features = false } structopt = "0.3.2" diff --git a/meilisearch-core/src/update/documents_addition.rs b/meilisearch-core/src/update/documents_addition.rs index 2a2fe978a..77275b552 100644 --- a/meilisearch-core/src/update/documents_addition.rs +++ b/meilisearch-core/src/update/documents_addition.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use fst::{set::OpBuilder, SetBuilder}; +use indexmap::IndexMap; use sdset::{duo::Union, SetOperation}; use serde::{Deserialize, Serialize}; @@ -105,7 +106,7 @@ pub fn push_documents_addition( pub fn apply_documents_addition<'a, 'b>( writer: &'a mut heed::RwTxn<'b, MainT>, index: &store::Index, - addition: Vec>, + addition: Vec>, ) -> MResult<()> { let mut documents_additions = HashMap::new(); @@ -174,7 +175,7 @@ pub fn apply_documents_addition<'a, 'b>( pub fn apply_documents_partial_addition<'a, 'b>( writer: &'a mut heed::RwTxn<'b, MainT>, index: &store::Index, - addition: Vec>, + addition: Vec>, ) -> MResult<()> { let mut documents_additions = HashMap::new(); diff --git a/meilisearch-core/src/update/mod.rs b/meilisearch-core/src/update/mod.rs index f13429917..d9a2d41a7 100644 --- a/meilisearch-core/src/update/mod.rs +++ b/meilisearch-core/src/update/mod.rs @@ -13,15 +13,15 @@ pub use self::documents_deletion::{apply_documents_deletion, DocumentsDeletion}; pub use self::settings_update::{apply_settings_update, push_settings_update}; use std::cmp; -use std::collections::HashMap; use std::time::Instant; use chrono::{DateTime, Utc}; -use heed::Result as ZResult; -use log::debug; -use serde::{Deserialize, Serialize}; use fst::{IntoStreamer, Streamer}; +use heed::Result as ZResult; +use indexmap::IndexMap; +use log::debug; use sdset::Set; +use serde::{Deserialize, Serialize}; use crate::{store, DocumentId, MResult}; use crate::database::{MainT, UpdateT}; @@ -48,14 +48,14 @@ impl Update { } } - fn documents_addition(data: Vec>) -> Update { + fn documents_addition(data: Vec>) -> Update { Update { data: UpdateData::DocumentsAddition(data), enqueued_at: Utc::now(), } } - fn documents_partial(data: Vec>) -> Update { + fn documents_partial(data: Vec>) -> Update { Update { data: UpdateData::DocumentsPartial(data), enqueued_at: Utc::now(), @@ -81,8 +81,8 @@ impl Update { pub enum UpdateData { ClearAll, Customs(Vec), - DocumentsAddition(Vec>), - DocumentsPartial(Vec>), + DocumentsAddition(Vec>), + DocumentsPartial(Vec>), DocumentsDeletion(Vec), Settings(SettingsUpdate) } diff --git a/meilisearch-http/src/routes/setting.rs b/meilisearch-http/src/routes/setting.rs index b0b5ce8ea..19f26ec4c 100644 --- a/meilisearch-http/src/routes/setting.rs +++ b/meilisearch-http/src/routes/setting.rs @@ -290,7 +290,7 @@ pub async fn get_searchable(ctx: Request) -> SResult { let schema = index.main.schema(&reader)?; - let searchable_attributes: Option> = + let searchable_attributes: Option> = schema.map(|s| s.indexed_name().iter().map(|i| (*i).to_string()).collect()); Ok(tide::Response::new(200)