From da718212045af975ee26c7dddceb2c64ec6b433d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Thu, 17 Oct 2019 13:05:11 +0200 Subject: [PATCH 1/2] Make the example take the fetch-timeout-ms argument into account --- meilidb-core/examples/from_file.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/meilidb-core/examples/from_file.rs b/meilidb-core/examples/from_file.rs index a5d8564f2..9ab074c3a 100644 --- a/meilidb-core/examples/from_file.rs +++ b/meilidb-core/examples/from_file.rs @@ -285,6 +285,13 @@ fn search_command(command: SearchCommand, database: Database) -> Result<(), Box< Ok(query) => { let start_total = Instant::now(); + let builder = index.query_builder(); + let builder = if let Some(timeout) = command.fetch_timeout_ms { + builder.with_fetch_timeout(Duration::from_millis(timeout)) + } else { + builder + }; + let documents = match command.filter { Some(ref filter) => { let filter = filter.as_str(); @@ -296,15 +303,14 @@ fn search_command(command: SearchCommand, database: Database) -> Result<(), Box< let attr = schema.attribute(&filter).expect("Could not find filtered attribute"); - let builder = index.query_builder(); let builder = builder.with_filter(|document_id| { let string: String = index.document_attribute(&reader, document_id, attr).unwrap().unwrap(); (string == "true") == positive }); + builder.query(&reader, &query, 0..command.number_results)? }, None => { - let builder = index.query_builder(); builder.query(&reader, &query, 0..command.number_results)? } }; From 2ea3e9b081160a8447c6456b1b987c28a3a1a99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Thu, 17 Oct 2019 13:08:00 +0200 Subject: [PATCH 2/2] Improve the automaton producer quality by changing the production order --- meilidb-core/src/automaton/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meilidb-core/src/automaton/mod.rs b/meilidb-core/src/automaton/mod.rs index 4281a8c21..0f7e3137d 100644 --- a/meilidb-core/src/automaton/mod.rs +++ b/meilidb-core/src/automaton/mod.rs @@ -210,9 +210,9 @@ fn generate_automatons( // order automatons, the most important first, // we keep the original automatons at the front. - automatons[1..].sort_unstable_by_key(|a| { + automatons[1..].sort_by_key(|a| { let a = a.first().unwrap(); - (Reverse(a.is_exact), Reverse(a.ngram)) + (Reverse(a.is_exact), a.ngram) }); Ok((automatons, enhancer_builder.build()))