mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-31 23:41:42 +08:00
Multi search reads header to know if it is being proxied
This commit is contained in:
parent
04b01cc146
commit
837905fc04
@ -20,6 +20,7 @@ use crate::routes::indexes::search::search_kind;
|
|||||||
use crate::search::{
|
use crate::search::{
|
||||||
add_search_rules, perform_federated_search, perform_search, FederatedSearch,
|
add_search_rules, perform_federated_search, perform_search, FederatedSearch,
|
||||||
FederatedSearchResult, RetrieveVectors, SearchQueryWithIndex, SearchResultWithIndex,
|
FederatedSearchResult, RetrieveVectors, SearchQueryWithIndex, SearchResultWithIndex,
|
||||||
|
PROXY_SEARCH_HEADER, PROXY_SEARCH_HEADER_VALUE,
|
||||||
};
|
};
|
||||||
use crate::search_queue::SearchQueue;
|
use crate::search_queue::SearchQueue;
|
||||||
|
|
||||||
@ -187,18 +188,22 @@ pub async fn multi_search_with_post(
|
|||||||
|
|
||||||
let response = match federation {
|
let response = match federation {
|
||||||
Some(federation) => {
|
Some(federation) => {
|
||||||
let search_result = tokio::task::spawn_blocking(move || {
|
// check remote header
|
||||||
perform_federated_search(&index_scheduler, queries, federation, features)
|
let is_proxy = req
|
||||||
})
|
.headers()
|
||||||
|
.get(PROXY_SEARCH_HEADER)
|
||||||
|
.is_some_and(|value| value.as_bytes() == PROXY_SEARCH_HEADER_VALUE.as_bytes());
|
||||||
|
let search_result =
|
||||||
|
perform_federated_search(&index_scheduler, queries, federation, features, is_proxy)
|
||||||
.await;
|
.await;
|
||||||
permit.drop().await;
|
permit.drop().await;
|
||||||
|
|
||||||
if let Ok(Ok(_)) = search_result {
|
if search_result.is_ok() {
|
||||||
multi_aggregate.succeed();
|
multi_aggregate.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
analytics.publish(multi_aggregate, &req);
|
analytics.publish(multi_aggregate, &req);
|
||||||
HttpResponse::Ok().json(search_result??)
|
HttpResponse::Ok().json(search_result?)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// Explicitly expect a `(ResponseError, usize)` for the error type rather than `ResponseError` only,
|
// Explicitly expect a `(ResponseError, usize)` for the error type rather than `ResponseError` only,
|
||||||
|
@ -41,7 +41,7 @@ use crate::error::MeilisearchHttpError;
|
|||||||
mod federated;
|
mod federated;
|
||||||
pub use federated::{
|
pub use federated::{
|
||||||
perform_federated_search, FederatedSearch, FederatedSearchResult, Federation,
|
perform_federated_search, FederatedSearch, FederatedSearchResult, Federation,
|
||||||
FederationOptions, MergeFacets,
|
FederationOptions, MergeFacets, PROXY_SEARCH_HEADER, PROXY_SEARCH_HEADER_VALUE,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod ranking_rules;
|
mod ranking_rules;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user