From ea308eb798888dd73d141fa41424a67652ee241b Mon Sep 17 00:00:00 2001 From: Quentin de Quelen Date: Fri, 24 Apr 2020 18:18:40 +0200 Subject: [PATCH] remove timeout search query parameter fix requested changes --- meilisearch-http/src/helpers/authentication.rs | 1 + meilisearch-http/src/helpers/meilisearch.rs | 13 ++----------- meilisearch-http/src/main.rs | 6 +++--- meilisearch-http/src/routes/search.rs | 6 ------ 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/meilisearch-http/src/helpers/authentication.rs b/meilisearch-http/src/helpers/authentication.rs index de62e22f3..f91b7c3c5 100644 --- a/meilisearch-http/src/helpers/authentication.rs +++ b/meilisearch-http/src/helpers/authentication.rs @@ -17,6 +17,7 @@ pub enum Authentication { Admin, } + impl Transform for Authentication where S: Service, Error = Error>, diff --git a/meilisearch-http/src/helpers/meilisearch.rs b/meilisearch-http/src/helpers/meilisearch.rs index 2cd9d3379..59bef52f4 100644 --- a/meilisearch-http/src/helpers/meilisearch.rs +++ b/meilisearch-http/src/helpers/meilisearch.rs @@ -1,7 +1,7 @@ use std::cmp::Ordering; use std::collections::{HashMap, HashSet}; use std::hash::{Hash, Hasher}; -use std::time::{Duration, Instant}; +use std::time::Instant; use indexmap::IndexMap; use log::error; @@ -33,7 +33,6 @@ impl IndexSearchExt for Index { attributes_to_retrieve: None, attributes_to_highlight: None, filters: None, - timeout: Duration::from_millis(30), matches: false, } } @@ -48,7 +47,6 @@ pub struct SearchBuilder<'a> { attributes_to_retrieve: Option>, attributes_to_highlight: Option>, filters: Option, - timeout: Duration, matches: bool, } @@ -89,11 +87,6 @@ impl<'a> SearchBuilder<'a> { self } - pub fn timeout(&mut self, value: Duration) -> &SearchBuilder { - self.timeout = value; - self - } - pub fn get_matches(&mut self) -> &SearchBuilder { self.matches = true; self @@ -130,8 +123,6 @@ impl<'a> SearchBuilder<'a> { }); } - query_builder.with_fetch_timeout(self.timeout); - if let Some(field) = self.index.main.distinct_attribute(reader)? { if let Some(field_id) = schema.id(&field) { query_builder.with_distinct(1, move |id| { @@ -192,7 +183,7 @@ impl<'a> SearchBuilder<'a> { .document(reader, attributes.as_ref(), doc.id) .map_err(|e| ResponseError::retrieve_document(doc.id.0, e))? .ok_or(ResponseError::internal( - "Impossible to retrieve a document id returned by the engine", + "Impossible to retrieve the document; Corrupted data", ))?; let mut formatted = document.iter() diff --git a/meilisearch-http/src/main.rs b/meilisearch-http/src/main.rs index f802dab33..637bfaddb 100644 --- a/meilisearch-http/src/main.rs +++ b/meilisearch-http/src/main.rs @@ -15,11 +15,11 @@ mod analytics; #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; -#[tokio::main] +#[actix_rt::main] async fn main() -> Result<(), MainError> { let opt = Opt::from_args(); - let local = tokio::task::LocalSet::new(); - let _sys = actix_rt::System::run_in_tokio("server", &local); + // let local = tokio::task::LocalSet::new(); + // let _sys = actix_rt::System::run_in_tokio("server", &local); match opt.env.as_ref() { "production" => { diff --git a/meilisearch-http/src/routes/search.rs b/meilisearch-http/src/routes/search.rs index f448553bf..e64550448 100644 --- a/meilisearch-http/src/routes/search.rs +++ b/meilisearch-http/src/routes/search.rs @@ -1,5 +1,4 @@ use std::collections::{HashSet, HashMap}; -use std::time::Duration; use log::warn; use actix_web::web; @@ -27,7 +26,6 @@ struct SearchQuery { crop_length: Option, attributes_to_highlight: Option, filters: Option, - timeout_ms: Option, matches: Option, } @@ -133,10 +131,6 @@ async fn search_with_url_query( search_builder.filters(filters.to_string()); } - if let Some(timeout_ms) = params.timeout_ms { - search_builder.timeout(Duration::from_millis(timeout_ms)); - } - if let Some(matches) = params.matches { if matches { search_builder.get_matches();