mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 10:37:41 +08:00
Merge pull request #204 from meilisearch/optional-query-builder-timeout
Make the timeout QueryBuilder setting optional to and pass the tests
This commit is contained in:
commit
9ed6752573
@ -19,7 +19,7 @@ pub struct QueryBuilder<'c, FI = fn(DocumentId) -> bool> {
|
|||||||
criteria: Criteria<'c>,
|
criteria: Criteria<'c>,
|
||||||
searchable_attrs: Option<ReorderedAttrs>,
|
searchable_attrs: Option<ReorderedAttrs>,
|
||||||
filter: Option<FI>,
|
filter: Option<FI>,
|
||||||
timeout: Duration,
|
timeout: Option<Duration>,
|
||||||
main_store: store::Main,
|
main_store: store::Main,
|
||||||
postings_lists_store: store::PostingsLists,
|
postings_lists_store: store::PostingsLists,
|
||||||
synonyms_store: store::Synonyms,
|
synonyms_store: store::Synonyms,
|
||||||
@ -211,7 +211,7 @@ impl<'c> QueryBuilder<'c> {
|
|||||||
criteria,
|
criteria,
|
||||||
searchable_attrs: None,
|
searchable_attrs: None,
|
||||||
filter: None,
|
filter: None,
|
||||||
timeout: Duration::from_millis(30),
|
timeout: None,
|
||||||
main_store: main,
|
main_store: main,
|
||||||
postings_lists_store: postings_lists,
|
postings_lists_store: postings_lists,
|
||||||
synonyms_store: synonyms,
|
synonyms_store: synonyms,
|
||||||
@ -235,7 +235,7 @@ impl<'c, FI> QueryBuilder<'c, FI> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_fetch_timeout(self, timeout: Duration) -> QueryBuilder<'c, FI> {
|
pub fn with_fetch_timeout(self, timeout: Duration) -> QueryBuilder<'c, FI> {
|
||||||
QueryBuilder { timeout, ..self }
|
QueryBuilder { timeout: Some(timeout), ..self }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_distinct<F, K>(self, function: F, size: usize) -> DistinctQueryBuilder<'c, FI, F>
|
pub fn with_distinct<F, K>(self, function: F, size: usize) -> DistinctQueryBuilder<'c, FI, F>
|
||||||
@ -295,9 +295,11 @@ impl<FI> QueryBuilder<'_, FI> where FI: Fn(DocumentId) -> bool {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
// stop processing when time is running out
|
// stop processing when time is running out
|
||||||
if !raw_documents_processed.is_empty() && start_processing.elapsed() > self.timeout {
|
if let Some(timeout) = self.timeout {
|
||||||
|
if !raw_documents_processed.is_empty() && start_processing.elapsed() > timeout {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut groups = vec![raw_documents.as_mut_slice()];
|
let mut groups = vec![raw_documents.as_mut_slice()];
|
||||||
|
|
||||||
@ -334,7 +336,9 @@ impl<FI> QueryBuilder<'_, FI> where FI: Fn(DocumentId) -> bool {
|
|||||||
raw_documents_processed.extend(iter);
|
raw_documents_processed.extend(iter);
|
||||||
|
|
||||||
// stop processing when time is running out
|
// stop processing when time is running out
|
||||||
if start_processing.elapsed() > self.timeout { break }
|
if let Some(timeout) = self.timeout {
|
||||||
|
if start_processing.elapsed() > timeout { break }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make real documents now that we know
|
// make real documents now that we know
|
||||||
@ -419,9 +423,11 @@ where FI: Fn(DocumentId) -> bool,
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
// stop processing when time is running out
|
// stop processing when time is running out
|
||||||
if !raw_documents_processed.is_empty() && start_processing.elapsed() > self.inner.timeout {
|
if let Some(timeout) = self.inner.timeout {
|
||||||
|
if !raw_documents_processed.is_empty() && start_processing.elapsed() > timeout {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut groups = vec![raw_documents.as_mut_slice()];
|
let mut groups = vec![raw_documents.as_mut_slice()];
|
||||||
let mut key_cache = HashMap::new();
|
let mut key_cache = HashMap::new();
|
||||||
@ -517,7 +523,9 @@ where FI: Fn(DocumentId) -> bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stop processing when time is running out
|
// stop processing when time is running out
|
||||||
if start_processing.elapsed() > self.inner.timeout { break }
|
if let Some(timeout) = self.inner.timeout {
|
||||||
|
if start_processing.elapsed() > timeout { break }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make real documents now that we know
|
// make real documents now that we know
|
||||||
|
Loading…
Reference in New Issue
Block a user