Merge pull request #507 from meilisearch/fix-documents-fields-order-inference

Fix the inference of the documents searchable fields
This commit is contained in:
Quentin de Quelen 2020-03-04 14:16:36 +01:00 committed by GitHub
commit 1cb9f75026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 13 deletions

View File

@ -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"

View File

@ -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<D: serde::Serialize>(
pub fn apply_documents_addition<'a, 'b>(
writer: &'a mut heed::RwTxn<'b, MainT>,
index: &store::Index,
addition: Vec<HashMap<String, serde_json::Value>>,
addition: Vec<IndexMap<String, serde_json::Value>>,
) -> 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<HashMap<String, serde_json::Value>>,
addition: Vec<IndexMap<String, serde_json::Value>>,
) -> MResult<()> {
let mut documents_additions = HashMap::new();

View File

@ -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<HashMap<String, serde_json::Value>>) -> Update {
fn documents_addition(data: Vec<IndexMap<String, serde_json::Value>>) -> Update {
Update {
data: UpdateData::DocumentsAddition(data),
enqueued_at: Utc::now(),
}
}
fn documents_partial(data: Vec<HashMap<String, serde_json::Value>>) -> Update {
fn documents_partial(data: Vec<IndexMap<String, serde_json::Value>>) -> Update {
Update {
data: UpdateData::DocumentsPartial(data),
enqueued_at: Utc::now(),
@ -81,8 +81,8 @@ impl Update {
pub enum UpdateData {
ClearAll,
Customs(Vec<u8>),
DocumentsAddition(Vec<HashMap<String, serde_json::Value>>),
DocumentsPartial(Vec<HashMap<String, serde_json::Value>>),
DocumentsAddition(Vec<IndexMap<String, serde_json::Value>>),
DocumentsPartial(Vec<IndexMap<String, serde_json::Value>>),
DocumentsDeletion(Vec<DocumentId>),
Settings(SettingsUpdate)
}

View File

@ -290,7 +290,7 @@ pub async fn get_searchable(ctx: Request<Data>) -> SResult<Response> {
let schema = index.main.schema(&reader)?;
let searchable_attributes: Option<HashSet<String>> =
let searchable_attributes: Option<Vec<String>> =
schema.map(|s| s.indexed_name().iter().map(|i| (*i).to_string()).collect());
Ok(tide::Response::new(200)