mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 00:55:00 +08:00
Update new sort ranking rule after rebasing
This commit is contained in:
parent
fbb1ba3de0
commit
65474c8de5
@ -68,30 +68,52 @@ impl<'ctx, Query: RankingRuleQueryTrait> RankingRule<'ctx, Query> for Sort<'ctx,
|
||||
) -> Result<()> {
|
||||
let iter: RankingRuleOutputIterWrapper<Query> = match self.field_id {
|
||||
Some(field_id) => {
|
||||
let make_iter =
|
||||
if self.is_ascending { ascending_facet_sort } else { descending_facet_sort };
|
||||
|
||||
let number_iter = make_iter(
|
||||
ctx.txn,
|
||||
ctx.index
|
||||
let number_db = ctx
|
||||
.index
|
||||
.facet_id_f64_docids
|
||||
.remap_key_type::<FacetGroupKeyCodec<ByteSliceRefCodec>>(),
|
||||
.remap_key_type::<FacetGroupKeyCodec<ByteSliceRefCodec>>();
|
||||
let string_db = ctx
|
||||
.index
|
||||
.facet_id_string_docids
|
||||
.remap_key_type::<FacetGroupKeyCodec<ByteSliceRefCodec>>();
|
||||
|
||||
let (number_iter, string_iter) = if self.is_ascending {
|
||||
let number_iter = ascending_facet_sort(
|
||||
ctx.txn,
|
||||
number_db,
|
||||
field_id,
|
||||
parent_candidates.clone(),
|
||||
)?;
|
||||
let string_iter = ascending_facet_sort(
|
||||
ctx.txn,
|
||||
string_db,
|
||||
field_id,
|
||||
parent_candidates.clone(),
|
||||
)?;
|
||||
|
||||
let string_iter = make_iter(
|
||||
(itertools::Either::Left(number_iter), itertools::Either::Left(string_iter))
|
||||
} else {
|
||||
let number_iter = descending_facet_sort(
|
||||
ctx.txn,
|
||||
ctx.index
|
||||
.facet_id_string_docids
|
||||
.remap_key_type::<FacetGroupKeyCodec<ByteSliceRefCodec>>(),
|
||||
number_db,
|
||||
field_id,
|
||||
parent_candidates.clone(),
|
||||
)?;
|
||||
let string_iter = descending_facet_sort(
|
||||
ctx.txn,
|
||||
string_db,
|
||||
field_id,
|
||||
parent_candidates.clone(),
|
||||
)?;
|
||||
|
||||
(itertools::Either::Right(number_iter), itertools::Either::Right(string_iter))
|
||||
};
|
||||
|
||||
let query_graph = parent_query_graph.clone();
|
||||
RankingRuleOutputIterWrapper::new(Box::new(number_iter.chain(string_iter).map(
|
||||
move |docids| {
|
||||
Ok(RankingRuleOutput { query: query_graph.clone(), candidates: docids? })
|
||||
move |r| {
|
||||
let (docids, _) = r?;
|
||||
Ok(RankingRuleOutput { query: query_graph.clone(), candidates: docids })
|
||||
},
|
||||
)))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user