|
1 | 1 | use crate::{ |
2 | | - client::Client, errors::Error, indexes::Index, request::HttpClient, DefaultHttpClient, |
| 2 | + client::Client, errors::{Error, MeilisearchError}, indexes::Index, request::HttpClient, DefaultHttpClient, |
3 | 3 | }; |
4 | 4 | use either::Either; |
5 | 5 | use serde::{de::DeserializeOwned, Deserialize, Serialize, Serializer}; |
@@ -822,37 +822,58 @@ impl<'a, Http: HttpClient> FederatedMultiSearchQuery<'a, '_, Http> { |
822 | 822 | } |
823 | 823 | } |
824 | 824 |
|
| 825 | +#[derive(Debug, Clone, Default, Serialize, Deserialize)] |
| 826 | +pub struct ComputedFacets { |
| 827 | + pub distribution: HashMap<String, HashMap<String, u64>>, |
| 828 | + pub stats: HashMap<String, FacetStats>, |
| 829 | +} |
| 830 | + |
825 | 831 | /// Returned by federated multi search. |
826 | 832 | #[derive(Debug, Deserialize, Clone)] |
827 | 833 | #[serde(rename_all = "camelCase")] |
828 | 834 | pub struct FederatedMultiSearchResponse<T> { |
829 | 835 | /// Merged results of the query. |
830 | 836 | pub hits: Vec<SearchResult<T>>, |
831 | 837 |
|
832 | | - // TODO: are offset, limit and estimated_total_hits really non-optional? In |
833 | | - // my tests they are always returned, but that's not a proof. |
834 | 838 | /// Number of documents skipped. |
835 | 839 | pub offset: usize, |
| 840 | + |
836 | 841 | /// Number of results returned. |
837 | 842 | pub limit: usize, |
| 843 | + |
838 | 844 | /// Estimated total number of matches. |
839 | 845 | pub estimated_total_hits: usize, |
840 | 846 |
|
841 | | - /// Distribution of the given facets. |
842 | | - pub facet_distribution: Option<HashMap<String, HashMap<String, usize>>>, |
843 | | - /// facet stats of the numerical facets requested in the `facet` search parameter. |
844 | | - pub facet_stats: Option<HashMap<String, FacetStats>>, |
845 | 847 | /// Processing time of the query. |
846 | 848 | pub processing_time_ms: usize, |
| 849 | + |
| 850 | + /// [Data for facets present in the search results](https://www.meilisearch.com/docs/reference/api/multi_search#facetsbyindex) |
| 851 | + pub facets_by_index: Option<ComputedFacets>, |
| 852 | + |
| 853 | + /// [Distribution of the given facets](https://www.meilisearch.com/docs/reference/api/multi_search#mergefacets) |
| 854 | + pub facet_distribution: Option<HashMap<String, HashMap<String, usize>>>, |
| 855 | + |
| 856 | + /// [The numeric `min` and `max` values per facet](https://www.meilisearch.com/docs/reference/api/multi_search#mergefacets) |
| 857 | + pub facet_stats: Option<HashMap<String, FacetStats>>, |
| 858 | + |
| 859 | + /// Indicates which remote requests failed and why |
| 860 | + pub remote_errors: Option<HashMap<String, MeilisearchError>>, |
847 | 861 | } |
848 | 862 |
|
849 | 863 | /// Returned for each hit in `_federation` when doing federated multi search. |
850 | 864 | #[derive(Serialize, Deserialize, Debug, Clone)] |
851 | 865 | #[serde(rename_all = "camelCase")] |
852 | 866 | pub struct FederationHitInfo { |
| 867 | + /// Index of origin for this document |
853 | 868 | pub index_uid: String, |
| 869 | + |
| 870 | + /// Array index number of the query in the request’s queries array |
854 | 871 | pub queries_position: usize, |
855 | | - // TOOD: not mentioned in the docs, is that optional? |
| 872 | + |
| 873 | + /// Remote instance of origin for this document |
| 874 | + pub remote: Option<String>, |
| 875 | + |
| 876 | + /// The product of the _rankingScore of the hit and the weight of the query of origin. |
856 | 877 | pub weighted_ranking_score: f32, |
857 | 878 | } |
858 | 879 |
|
|
0 commit comments