mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-02-23 19:15:31 +08:00
Compare commits
3 Commits
72ad94bd5d
...
8ad92f7eb0
Author | SHA1 | Date | |
---|---|---|---|
|
8ad92f7eb0 | ||
|
9951f5c8b3 | ||
|
f4f372e113 |
@ -13,8 +13,6 @@ pub struct MultiSearchAggregator {
|
|||||||
|
|
||||||
// sum of the number of distinct indexes in each single request, use with total_received to compute an avg
|
// sum of the number of distinct indexes in each single request, use with total_received to compute an avg
|
||||||
total_distinct_index_count: usize,
|
total_distinct_index_count: usize,
|
||||||
// sum of the number of distinct remotes in each single request, use with total_received to compute an avg
|
|
||||||
total_distinct_remote_count: usize,
|
|
||||||
// number of queries with a single index, use with total_received to compute a proportion
|
// number of queries with a single index, use with total_received to compute a proportion
|
||||||
total_single_index: usize,
|
total_single_index: usize,
|
||||||
|
|
||||||
@ -33,13 +31,15 @@ impl MultiSearchAggregator {
|
|||||||
pub fn from_federated_search(federated_search: &FederatedSearch) -> Self {
|
pub fn from_federated_search(federated_search: &FederatedSearch) -> Self {
|
||||||
let use_federation = federated_search.federation.is_some();
|
let use_federation = federated_search.federation.is_some();
|
||||||
|
|
||||||
let mut distinct_indexes = HashSet::with_capacity(federated_search.queries.len());
|
let distinct_indexes: HashSet<_> = federated_search
|
||||||
let mut distinct_remotes = HashSet::with_capacity(federated_search.queries.len());
|
.queries
|
||||||
|
.iter()
|
||||||
|
.map(|query| {
|
||||||
|
let query = &query;
|
||||||
// make sure we get a compilation error if a field gets added to / removed from SearchQueryWithIndex
|
// make sure we get a compilation error if a field gets added to / removed from SearchQueryWithIndex
|
||||||
for SearchQueryWithIndex {
|
let SearchQueryWithIndex {
|
||||||
index_uid,
|
index_uid,
|
||||||
federation_options,
|
federation_options: _,
|
||||||
q: _,
|
q: _,
|
||||||
vector: _,
|
vector: _,
|
||||||
offset: _,
|
offset: _,
|
||||||
@ -66,16 +66,11 @@ impl MultiSearchAggregator {
|
|||||||
hybrid: _,
|
hybrid: _,
|
||||||
ranking_score_threshold: _,
|
ranking_score_threshold: _,
|
||||||
locales: _,
|
locales: _,
|
||||||
} in &federated_search.queries
|
} = query;
|
||||||
{
|
|
||||||
if let Some(federation_options) = federation_options {
|
|
||||||
if let Some(remote) = &federation_options.remote {
|
|
||||||
distinct_remotes.insert(remote.as_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
distinct_indexes.insert(index_uid.as_str());
|
index_uid.as_str()
|
||||||
}
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
let show_ranking_score =
|
let show_ranking_score =
|
||||||
federated_search.queries.iter().any(|query| query.show_ranking_score);
|
federated_search.queries.iter().any(|query| query.show_ranking_score);
|
||||||
@ -86,7 +81,6 @@ impl MultiSearchAggregator {
|
|||||||
total_received: 1,
|
total_received: 1,
|
||||||
total_succeeded: 0,
|
total_succeeded: 0,
|
||||||
total_distinct_index_count: distinct_indexes.len(),
|
total_distinct_index_count: distinct_indexes.len(),
|
||||||
total_distinct_remote_count: distinct_remotes.len(),
|
|
||||||
total_single_index: if distinct_indexes.len() == 1 { 1 } else { 0 },
|
total_single_index: if distinct_indexes.len() == 1 { 1 } else { 0 },
|
||||||
total_search_count: federated_search.queries.len(),
|
total_search_count: federated_search.queries.len(),
|
||||||
show_ranking_score,
|
show_ranking_score,
|
||||||
@ -116,8 +110,6 @@ impl Aggregate for MultiSearchAggregator {
|
|||||||
let total_succeeded = this.total_succeeded.saturating_add(new.total_succeeded);
|
let total_succeeded = this.total_succeeded.saturating_add(new.total_succeeded);
|
||||||
let total_distinct_index_count =
|
let total_distinct_index_count =
|
||||||
this.total_distinct_index_count.saturating_add(new.total_distinct_index_count);
|
this.total_distinct_index_count.saturating_add(new.total_distinct_index_count);
|
||||||
let total_distinct_remote_count =
|
|
||||||
this.total_distinct_remote_count.saturating_add(new.total_distinct_remote_count);
|
|
||||||
let total_single_index = this.total_single_index.saturating_add(new.total_single_index);
|
let total_single_index = this.total_single_index.saturating_add(new.total_single_index);
|
||||||
let total_search_count = this.total_search_count.saturating_add(new.total_search_count);
|
let total_search_count = this.total_search_count.saturating_add(new.total_search_count);
|
||||||
let show_ranking_score = this.show_ranking_score || new.show_ranking_score;
|
let show_ranking_score = this.show_ranking_score || new.show_ranking_score;
|
||||||
@ -129,7 +121,6 @@ impl Aggregate for MultiSearchAggregator {
|
|||||||
total_received,
|
total_received,
|
||||||
total_succeeded,
|
total_succeeded,
|
||||||
total_distinct_index_count,
|
total_distinct_index_count,
|
||||||
total_distinct_remote_count,
|
|
||||||
total_single_index,
|
total_single_index,
|
||||||
total_search_count,
|
total_search_count,
|
||||||
show_ranking_score,
|
show_ranking_score,
|
||||||
@ -143,7 +134,6 @@ impl Aggregate for MultiSearchAggregator {
|
|||||||
total_received,
|
total_received,
|
||||||
total_succeeded,
|
total_succeeded,
|
||||||
total_distinct_index_count,
|
total_distinct_index_count,
|
||||||
total_distinct_remote_count,
|
|
||||||
total_single_index,
|
total_single_index,
|
||||||
total_search_count,
|
total_search_count,
|
||||||
show_ranking_score,
|
show_ranking_score,
|
||||||
@ -162,10 +152,6 @@ impl Aggregate for MultiSearchAggregator {
|
|||||||
"total_distinct_index_count": total_distinct_index_count,
|
"total_distinct_index_count": total_distinct_index_count,
|
||||||
"avg_distinct_index_count": (total_distinct_index_count as f64) / (total_received as f64), // not 0 else returned early
|
"avg_distinct_index_count": (total_distinct_index_count as f64) / (total_received as f64), // not 0 else returned early
|
||||||
},
|
},
|
||||||
"remotes": {
|
|
||||||
"total_distinct_remote_count": total_distinct_remote_count,
|
|
||||||
"avg_distinct_index_count": (total_distinct_remote_count as f64) / (total_received as f64), // not 0 else returned early
|
|
||||||
},
|
|
||||||
"searches": {
|
"searches": {
|
||||||
"total_search_count": total_search_count,
|
"total_search_count": total_search_count,
|
||||||
"avg_search_count": (total_search_count as f64) / (total_received as f64),
|
"avg_search_count": (total_search_count as f64) / (total_received as f64),
|
||||||
|
@ -551,14 +551,11 @@ impl RemoteSearch {
|
|||||||
in_flight_remote_queries.insert(
|
in_flight_remote_queries.insert(
|
||||||
node_name,
|
node_name,
|
||||||
tokio::spawn({
|
tokio::spawn({
|
||||||
let mut proxy_federation = federation.clone();
|
let mut federation = federation.clone();
|
||||||
// fixup limit and offset to not apply them twice
|
|
||||||
proxy_federation.limit = federation.limit + federation.offset;
|
|
||||||
proxy_federation.offset = 0;
|
|
||||||
// never merge distant facets
|
// never merge distant facets
|
||||||
proxy_federation.merge_facets = None;
|
federation.merge_facets = None;
|
||||||
let params = params.clone();
|
let params = params.clone();
|
||||||
async move { proxy_search(&node, queries, proxy_federation, ¶ms).await }
|
async move { proxy_search(&node, queries, federation, ¶ms).await }
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user