mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
Extract the facet order before extracting the facets values
This commit is contained in:
parent
82b43e9a7f
commit
69c118ef76
@ -726,8 +726,15 @@ pub fn perform_facet_search(
|
|||||||
let rtxn = index.read_txn()?;
|
let rtxn = index.read_txn()?;
|
||||||
|
|
||||||
let (search, _, _, _) = prepare_search(index, &rtxn, &search_query, features, None)?;
|
let (search, _, _, _) = prepare_search(index, &rtxn, &search_query, features, None)?;
|
||||||
|
let sort_by = {
|
||||||
|
let sorts = index.sort_facet_values_by(&rtxn)?;
|
||||||
|
sorts
|
||||||
|
.get(&facet_name)
|
||||||
|
.copied()
|
||||||
|
.unwrap_or_else(|| sorts.get("*").copied().unwrap_or_default())
|
||||||
|
};
|
||||||
let mut facet_search =
|
let mut facet_search =
|
||||||
SearchForFacetValues::new(facet_name, search, search_query.hybrid.is_some());
|
SearchForFacetValues::new(facet_name, search, sort_by, search_query.hybrid.is_some());
|
||||||
if let Some(facet_query) = &facet_query {
|
if let Some(facet_query) = &facet_query {
|
||||||
facet_search.query(facet_query);
|
facet_search.query(facet_query);
|
||||||
}
|
}
|
||||||
|
@ -307,6 +307,7 @@ pub struct SearchForFacetValues<'a> {
|
|||||||
facet: String,
|
facet: String,
|
||||||
search_query: Search<'a>,
|
search_query: Search<'a>,
|
||||||
max_values: usize,
|
max_values: usize,
|
||||||
|
sort_by: OrderBy,
|
||||||
is_hybrid: bool,
|
is_hybrid: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,6 +315,7 @@ impl<'a> SearchForFacetValues<'a> {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
facet: String,
|
facet: String,
|
||||||
search_query: Search<'a>,
|
search_query: Search<'a>,
|
||||||
|
sort_by: OrderBy,
|
||||||
is_hybrid: bool,
|
is_hybrid: bool,
|
||||||
) -> SearchForFacetValues<'a> {
|
) -> SearchForFacetValues<'a> {
|
||||||
SearchForFacetValues {
|
SearchForFacetValues {
|
||||||
@ -321,6 +323,7 @@ impl<'a> SearchForFacetValues<'a> {
|
|||||||
facet,
|
facet,
|
||||||
search_query,
|
search_query,
|
||||||
max_values: DEFAULT_MAX_NUMBER_OF_VALUES_PER_FACET,
|
max_values: DEFAULT_MAX_NUMBER_OF_VALUES_PER_FACET,
|
||||||
|
sort_by,
|
||||||
is_hybrid,
|
is_hybrid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user