Skip to content

Commit b554c97

Browse files
committed
bugfix: inconsistent page size for hybrid group search
1 parent db2fe12 commit b554c97

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

server/src/operators/search_operator.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,7 +2885,7 @@ pub async fn hybrid_search_over_groups(
28852885

28862886
cross_encoder_results
28872887
.iter()
2888-
.chain(split_results.get(1).unwrap().iter())
2888+
.chain(split_results.iter().skip(1).flat_map(|chunk| chunk.iter()))
28892889
.cloned()
28902890
.collect::<Vec<GroupScoreChunk>>()
28912891
} else {
@@ -2901,24 +2901,29 @@ pub async fn hybrid_search_over_groups(
29012901
timer.add("reranking");
29022902

29032903
if let Some(score_threshold) = data.score_threshold {
2904-
reranked_chunks.retain(|chunk| {
2905-
chunk.metadata.get(0).map(|m| m.score).unwrap_or(0.0) >= score_threshold.into()
2904+
reranked_chunks.retain(|group_score_chunk| {
2905+
group_score_chunk
2906+
.metadata
2907+
.get(0)
2908+
.map(|m| m.score)
2909+
.unwrap_or(0.0)
2910+
>= score_threshold.into()
29062911
});
2907-
reranked_chunks.iter_mut().for_each(|chunk| {
2908-
chunk
2912+
reranked_chunks.iter_mut().for_each(|group_score_chunk| {
2913+
group_score_chunk
29092914
.metadata
29102915
.retain(|metadata| metadata.score >= score_threshold.into())
29112916
});
29122917
}
29132918

2919+
reranked_chunks.truncate(data.page_size.unwrap_or(10) as usize);
2920+
29142921
let result_chunks = DeprecatedSearchOverGroupsResponseBody {
29152922
group_chunks: reranked_chunks,
29162923
corrected_query: corrected_query.map(|c| c.query),
29172924
total_chunk_pages: combined_search_chunk_query_results.total_chunk_pages,
29182925
};
29192926

2920-
//TODO: rerank for groups
2921-
29222927
Ok(result_chunks)
29232928
}
29242929

0 commit comments

Comments
 (0)