mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-27 07:00:05 +01:00
Merge #1865
1865: Aggregate the search even when it fails fail r=MarinPostma a=irevoire Co-authored-by: Tamo <tamo@meilisearch.com>
This commit is contained in:
commit
4095ec462e
@ -18,7 +18,7 @@ impl SearchAggregator {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn finish(&mut self, _: &dyn Any) {}
|
||||
pub fn succeed(&mut self, _: &dyn Any) {}
|
||||
}
|
||||
|
||||
impl MockAnalytics {
|
||||
|
@ -364,7 +364,7 @@ impl SearchAggregator {
|
||||
ret
|
||||
}
|
||||
|
||||
pub fn finish(&mut self, result: &SearchResult) {
|
||||
pub fn succeed(&mut self, result: &SearchResult) {
|
||||
self.total_succeeded += 1;
|
||||
self.time_spent.push(result.processing_time_ms as usize);
|
||||
}
|
||||
|
@ -118,17 +118,18 @@ pub async fn search_with_url_query(
|
||||
|
||||
let mut aggregate = SearchAggregator::from_query(&query, &req);
|
||||
|
||||
let search_result = meilisearch
|
||||
.search(path.into_inner().index_uid, query)
|
||||
.await?;
|
||||
let search_result = meilisearch.search(path.into_inner().index_uid, query).await;
|
||||
if let Ok(ref search_result) = search_result {
|
||||
aggregate.succeed(search_result);
|
||||
}
|
||||
analytics.get_search(aggregate);
|
||||
|
||||
let search_result = search_result?;
|
||||
|
||||
// Tests that the nb_hits is always set to false
|
||||
#[cfg(test)]
|
||||
assert!(!search_result.exhaustive_nb_hits);
|
||||
|
||||
aggregate.finish(&search_result);
|
||||
analytics.get_search(aggregate);
|
||||
|
||||
debug!("returns: {:?}", search_result);
|
||||
Ok(HttpResponse::Ok().json(search_result))
|
||||
}
|
||||
@ -145,17 +146,18 @@ pub async fn search_with_post(
|
||||
|
||||
let mut aggregate = SearchAggregator::from_query(&query, &req);
|
||||
|
||||
let search_result = meilisearch
|
||||
.search(path.into_inner().index_uid, query)
|
||||
.await?;
|
||||
let search_result = meilisearch.search(path.into_inner().index_uid, query).await;
|
||||
if let Ok(ref search_result) = search_result {
|
||||
aggregate.succeed(search_result);
|
||||
}
|
||||
analytics.get_search(aggregate);
|
||||
|
||||
let search_result = search_result?;
|
||||
|
||||
// Tests that the nb_hits is always set to false
|
||||
#[cfg(test)]
|
||||
assert!(!search_result.exhaustive_nb_hits);
|
||||
|
||||
aggregate.finish(&search_result);
|
||||
analytics.post_search(aggregate);
|
||||
|
||||
debug!("returns: {:?}", search_result);
|
||||
Ok(HttpResponse::Ok().json(search_result))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user